⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hhl.java

📁 一个很好玩的小游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    contentPane.add(zl, null);
    contentPane.add(ok,null);
    contentPane.add(cance,null);
    ok.addActionListener(new ActionListener()
    			{
    				public void actionPerformed(ActionEvent e)
    					{
                             if(namearea.getText().length() < 1)
                             {
                                       JOptionPane.showMessageDialog(null,"不写名字也叫注册啊?");
                             }
                             else if(namearea.getText().length() > 6)
                             {
                                       JOptionPane.showMessageDialog(null,"那么长叫我怎么记啊?");
                             }
                             else
                             {
                                      if(passwordarea.getText().length() < 1)
                                     {
                                                 JOptionPane.showMessageDialog(null,"不写密码怎么注册啊?");

                                     }
                                 else if(passwordarea.getText().length()<6)
                                     {
                                                     JOptionPane.showMessageDialog(null,"密码太短了啊!!");
                                     }
                                     else
                                     {
                                             if(emailarea.getText().length() < 1)
                                             {
                                                     JOptionPane.showMessageDialog(null,"你这样写没人会联系你的喔!");
                                             }
                                             else
                                             {
                                                     if(i != 1)
                                                     {
                                                             JOptionPane.showMessageDialog(null,"是不是要给个猴头给你?");
                                                     }
                                                     else
                                                     {
                                                             dispose();
                                                             log l = new log(namearea.getText(),passwordarea.getText());
                                                             l.show(true);
                                                     }
                                             }
                                     }
                           }
                    }
                 });
    cance.addActionListener(new ActionListener()
    {
    	public void actionPerformed(ActionEvent e)
    	{
    	    dispose();
            log l = new log(null,null);
            l.show(true);
    	}
    });
    zl.getViewport().add(zlta, null);
    this.setVisible(true);
    this.setResizable(false);
  }

  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
}
//******************************************************************************





//****************************
//*                          *
//*                          *
//*          QQ部分          *
//*                          *
//*                          *
//****************************
//人员列表:显示上线人数用树的结构完成
//******************************************************************************


class face extends JFrame {
	

 //网络部分
  //******************************************
	user clientservice,clientget;
	qqclient clientChat;
	String name;

	thReceive tr;
	thSend ts;	
	int wakeup;
	
	Vector uList=new Vector(1); 


 //界面部分
 //********************************************
 
  
  JPanel online;
  JTree tree = new JTree();
  DefaultTreeCellRenderer r = new DefaultTreeCellRenderer();
  JScrollPane jsctree = new JScrollPane();
  DefaultMutableTreeNode tp1;
  DefaultTreeModel treeModel;
  String s[]=new String[20];
  String myname=new String();
  String spassword = new String();
  DefaultMutableTreeNode category = null;
  DefaultMutableTreeNode book = null;
  String passmyname;
  String serverip;
  Frame1 f1;
  
  JPopupMenu pm=new JPopupMenu();
  JMenuItem item1=new JMenuItem("添加好友");
  JMenuItem item2=new JMenuItem("接收文件");
  JMenuItem item3=new JMenuItem("发送消息");
  JMenuItem item4=new JMenuItem("系统参数");
  JMenuItem item5=new JMenuItem("删除好友");
  JMenuItem item6=new JMenuItem("退出QQ");

  face(String passname,String passpassword,String passserverip) {

    online = (JPanel) this.getContentPane();
    online.setLayout(null);


    //传递过来的参数
    //*****************************************
    myname = passname+"  的好友";
    passmyname = passname;
    spassword = passpassword;
    serverip = passserverip;
    
    //*****************************************
    tp1 = new DefaultMutableTreeNode(myname);
    treeModel=new DefaultTreeModel(tp1);
    tree=new JTree(treeModel);
    this.setSize(new Dimension(155, 520));
    this.setTitle(passname);
    this.setLocation(200,80);
    pm.add(item1);
	pm.add(item2);
	pm.add(item3);
	pm.add(item4);
	pm.add(item5);
	pm.add(item6);
	item1.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			new aa();
		}
		
	});
	item3.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			new aa();
		}
		
	});
	item4.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			new aa();
		}
		
	});
	item5.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			new aa();
		}
		
	});
	item2.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			 new getfile();
		}
	});
	item6.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			System.exit(0);
		}
	});	
    uList.addElement(passname);
    online.setOpaque(false);
    online.setVerifyInputWhenFocusTarget(false);
    online.setDoubleBuffered(false);
    online.setRequestFocusEnabled(false);
    online.add(pm);
    //tree.setCellRenderer(new R());
    r.setLeafIcon(new ImageIcon("image/qq.gif"));
    r.setOpenIcon(new ImageIcon("image/qq.gif"));
    r.setClosedIcon(new ImageIcon("image/qq.gif"));
    tree.setCellRenderer(r);
    tree.setShowsRootHandles(false);
    tree.setBorder(BorderFactory.createEtchedBorder());
    tree.setEditable(false);
    tree.setBounds(new Rectangle(5, 5, 139, 492));
    tree.addMouseListener(new java.awt.event.MouseAdapter()
    {	
    	
    	public void mouseClicked(MouseEvent e)
                  {
                        TreePath currentSelection = tree.getSelectionPath();
                        if(SwingUtilities.isLeftMouseButton(e)==true)
                        {
                         if (currentSelection != null&&e.getClickCount()==2)
                            {
                         			   DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)
                   												(currentSelection.getLastPathComponent());
                                       MutableTreeNode parent = (MutableTreeNode)(currentNode.getParent());
                              if (parent != null)
                                      {
                                              f1=new Frame1(tree.getSelectionPath().getLastPathComponent().toString(),passmyname,passmyname);
                                              f1.show(true);
                                              f1.setResizable(false);
                                       }
                             }
                          }
                          tree.clearSelection();  

                  }
  		public void mouseReleased(MouseEvent e)//鼠标右键事件
    				{
    					if(e.isPopupTrigger())
    					{
    						pm.show(online,e.getX(),e.getY());
    					}
    				}
    });   
    jsctree.setBounds(new Rectangle(5, 5, 139, 487));    
    online.add(jsctree, null);
    jsctree.getViewport().add(tree, null);
    
    clientChat=new qqclient(serverip,passname);
				wakeup=clientChat.connect();
				if (wakeup==0)
				{

					return;
				}

				clientget=(user)clientChat.get();
				if (clientget==null)
				{
					clientChat.disconnect();
					return;
				}
				
				tr=new thReceive();
				tr.start();
   
  }
  class aa 
  {
  	aa()
  	{
  		JOptionPane.showMessageDialog(null,"本人编的简单QQ程序没有此功能!");
  	}
  }


  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING)
    {
    	if(clientChat == null)
     	{
		 uList.clear();            
		 book = new DefaultMutableTreeNode(uList);
         tp1.add(book);
   		 clientChat.disconnect();
		}
    	System.exit(0);
    }
  }

class R extends DefaultTreeCellRenderer
  {
          ImageIcon icon1;
          ImageIcon icon2;
          ImageIcon icon3;
          ImageIcon icon4;
          ImageIcon icon5;
          ImageIcon icon6;
          ImageIcon icon7;
          ImageIcon icon8;
          ImageIcon icon9;
          ImageIcon icon10;
          ImageIcon icon11;
          ImageIcon icon12;
          ImageIcon icon13;
          public R()
          {
                  icon1 = new ImageIcon("image/face1.gif");
                  icon2 = new ImageIcon("image/face2.gif");
                  icon3 = new ImageIcon("image/face3.gif");
                  icon4 = new ImageIcon("image/face4.gif");
                  icon5 = new ImageIcon("image/face5.gif");
                  icon6 = new ImageIcon("image/face6.gif");
                  icon7 = new ImageIcon("image/face7.gif");
                  icon8 = new ImageIcon("image/face8.gif");
                  icon9 = new ImageIcon("image/face9.gif");
                  icon10 = new ImageIcon("image/face10.gif");
                  icon11 = new ImageIcon("image/face11.gif");
                  icon12 = new ImageIcon("image/face12.gif");
                  icon13 = new ImageIcon("image/face13.gif");
                  setOpenIcon(new ImageIcon("image/qq.gif"));
            setClosedIcon(new ImageIcon("image/qq.gif"));
          }
          public Component getTreeCellTendererComponent(JTree tree,
                                                                                                    Object value,
                                                                                                    boolean sel,
                                                                                                     boolean expanded,
                                                                                                     boolean leaf,
                                                                                                     int row,
                                                                                                     boolean hasFocus)
                                                                                                     {
                                                                                                             super.getTreeCellRendererComponent(tree,value,sel,
                                                                                                                                                                             expanded,leaf,row,
                                                                                                                                                                             hasFocus);
                                                                                                             if(leaf)
                                                                                                             {
                                                                                                                     DefaultMutableTreeNode note=(DefaultMutableTreeNode)value;
                                                                                                                     String strNote =note.toString();
                                                                                                                     if(strNote.equals("11"))setIcon(icon1);
                                                                                                                     if(strNote.equals("12"))setIcon(icon2);
                                                                                                                     if(strNote.equals("13"))setIcon(icon3);
                                                                                                                     if(strNote.equals("14"))setIcon(icon4);
                                                                                                                     if(strNote.equals("15"))setIcon(icon5);
                                                                                                                     if(strNote.equals("16"))setIcon(icon6);
                                                                                                                     if(strNote.equals("17"))setIcon(icon7);
                                                                                                                     if(strNote.equals("18"))setIcon(icon8);
                                                                                                                     if(strNote.equals("19"))setIcon(icon9);
                                                                                                                     if(strNote.equals("110"))setIcon(icon10);
                                                                                                                     if(strNote.equals("111"))setIcon(icon11);
                                                                                                                     if(strNote.equals("112"))setIcon(icon12);
                                                                                                                     if(strNote.equals("113"))setIcon(icon13);

                                                                                                             }
                                                                                                             return this;
                                                                                                     }
                    }
                    
                    
                    
//消息框:发送消息
//*****************************************************************************



 class Frame1 extends JFrame {

 //界面部分
 //****************************************
  JPanel jf;
  JLabel namearea = new JLabel();
  JLabel name = new JLabel();
  JLabel e_mailarea = new JLabel();
  JLabel e_mail = new JLabel();
  JLabel icon = new JLabel();
  JTextArea jt=new JTextArea();
  JScrollPane jsc = new JScrollPane();
  JLabel ip = new JLabel();
  JButton jb1 = new JButton("lts");
  JButton jb2 = new JButton("cswj");
  JLabel simple = new JLabel();
  ImageIcon icon1=new ImageIcon("image/1.gif");
  ImageIcon icon2=new ImageIcon("image/2.gif");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -