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

📄 hhl.java

📁 一个很好玩的小游戏
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import java.util.*;
import java.io.*;
import java.net.*;
import javax.swing.text.html.*;
import javax.swing.filechooser.*;
import sun.audio.*;


public class hhl extends JFrame
{
	
public static void main(String args[])
  {
          log log1=new log(null,null);
          log1.show(true);
          log1.setResizable(false);
  }
}

//传递的用户变量***************
//****************************************************************************

class user implements Serializable
{
        String usrName;
        String msg;
        String flag;
}
//***************************************************************************





//用户登陆面板,中间包括登陆和注册
//**************************************************************************


class log extends JFrame {
  JPanel contentPane;
  JLabel jL1 = new JLabel();
  JLabel name = new JLabel();
  JTextField namearea = new JTextField();
  JTextField serverip = new JTextField();
  JLabel pass = new JLabel();
  JLabel server = new JLabel();
  JPasswordField password = new JPasswordField();
  JButton login = new JButton(new ImageIcon("image/login.gif"));
  ImageIcon icon1=new ImageIcon("image/myself.jpg");
  JButton logout = new JButton(new ImageIcon("image/regit.gif"));
  String passstring,getpassword;


log(String passname,String passpassword){
    contentPane = (JPanel) this.getContentPane();
    jL1.setBorder(BorderFactory.createEtchedBorder());
    jL1.setHorizontalAlignment(SwingConstants.LEFT);
    jL1.setText("翰海林聊天");
    jL1.setIcon(icon1);
    jL1.addMouseListener(new MouseAdapter()
    {
    public void mouseClicked(MouseEvent e)
        {
                    JOptionPane.showMessageDialog(null,"你现在在用的是翰海林聊天室的的登陆界面");

        }
    });
    jL1.setBounds(new Rectangle(4, 13, 90, 120));
    contentPane.setLayout(null);
    this.setSize(new Dimension(300, 172));
    this.setTitle("翰海林聊天登陆");
    this.setLocation(400,250);
    passstring = passpassword;
    name.setFont(new java.awt.Font("Dialog", 0, 13));
    name.setHorizontalAlignment(SwingConstants.CENTER);
    name.setText("呢称:");
    name.setBounds(new Rectangle(96, 17, 42, 25));
    namearea.setFont(new java.awt.Font("Dialog", 0, 13));
    namearea.setBounds(new Rectangle(132, 14, 127, 27));
    namearea.setText(passname);
    pass.setFont(new java.awt.Font("Dialog", 0, 13));
    pass.setHorizontalAlignment(SwingConstants.CENTER);
    pass.setText("密码:");
    pass.setBounds(new Rectangle(96, 50, 45, 26));
    password.setFont(new java.awt.Font("Dialog", 0, 20));
    password.setForeground(Color.black);
    password.setEchoChar('*');
    password.setBounds(new Rectangle(132, 50, 129, 28));
    server.setBounds(new Rectangle(100, 80, 75, 20));
    server.setText("服务器ip:");
    serverip.setBounds(new Rectangle(160, 80, 100, 20));
    serverip.setText("127.0.0.1");
    login.setBounds(new Rectangle(130, 110, 50, 23));
    login.setFont(new java.awt.Font("Dialog", 0, 13));
    login.setHorizontalAlignment(SwingConstants.CENTER);
    login.setText("登陆");
    login.addActionListener(new ActionListener()
    {
    	public void actionPerformed(ActionEvent e)
    	{
    		
           if(namearea.getText().length()==0)
           {
                   JOptionPane.showMessageDialog(null,"对不起,你还没有说你是谁呢?难道要我叫你大笨蛋啊?");
    		}
           else if(namearea.getText().length()>6)
           {
                   JOptionPane.showMessageDialog(null,"你的名字太长了,叫人怎么记住您啊?");
   		   }
     	   else
   			 {
   				 if(password.getText().length()==0)
   				 {
   	    				     JOptionPane.showMessageDialog(null,"sorry,是不是所有人都可以用你的名字啊?填个密码吧!");
   				 }
   				 else if(password.getText().length()<6)
   				 {
  					          JOptionPane.showMessageDialog(null,"sorry,密码不得少于6位!");
				  }
				  
 				  else
 				   {
 				   	if(serverip.getText().length() < 8)
   				 	{
  					          JOptionPane.showMessageDialog(null,"请输入正确的服务器ip!");
				  	}
				  	else
				  	{
 				   		if(passstring == null)
 				   		{ 				   			
  					          JOptionPane.showMessageDialog(null,"你只是试用用户!试用期为一次");
 				   		}
 				   		else if(password.getText().compareTo(passstring)!=0)
 				   		{
  					          JOptionPane.showMessageDialog(null,"密码不正确!");
  					          return;
 				   		}
  						      dispose();
      				          face f=new face(namearea.getText(),password.getText(),serverip.getText());
         			          f.show(true);
         			          f.setResizable(false);
         			}
       			    }
   				}
    	}
    });
    logout.setBounds(new Rectangle(200, 110, 50, 23));
    logout.setFont(new java.awt.Font("Dialog", 0, 13));
    logout.setHorizontalAlignment(SwingConstants.CENTER);
    logout.setText("注册");
    logout.addActionListener(new ActionListener()
    {
    	public void actionPerformed(ActionEvent e)
    	{
    	   dispose();
           logout l = new logout();
           l.show(true);
    	}
    });
    contentPane.add(jL1, null);
    contentPane.add(pass, null);
    contentPane.add(password, null);
    contentPane.add(name, null);
    contentPane.add(namearea, null);
    contentPane.add(server,null);
    contentPane.add(serverip,null);
    contentPane.add(login, null);
    contentPane.add(logout, null);
    this.setVisible(true);
  }
}

//******************************************************************************





//注册部分
//******************************************************************************


class logout extends JFrame {
  JPanel contentPane;
  JLabel name = new JLabel();
  JTextField namearea = new JTextField();
  JLabel password = new JLabel();
  JTextField passwordarea = new JTextField();
  JLabel jp1 = new JLabel();
  JLabel email = new JLabel();
  JTextField emailarea = new JTextField();
  JLabel jp2 = new JLabel();
  JComboBox jcb = new JComboBox();
  JScrollPane zl = new JScrollPane();
  JTextArea zlta = new JTextArea();
  JButton ok = new JButton("确定");
  JButton cance = new JButton("取消");
  String[] s=new String[14];
  String ss = "选择你的头像";
  int i=0;
  ImageIcon icon = new ImageIcon("image/myself.jpg");
  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;
  ImageIcon icon14;


logout()
{
    icon1 = new ImageIcon("image/1.gif");
    icon2 = new ImageIcon("image/2.gif");
    icon3 = new ImageIcon("image/3.gif");
    icon4 = new ImageIcon("image/4.gif");
    icon5 = new ImageIcon("image/5.gif");
    icon6 = new ImageIcon("image/6.gif");
    icon7 = new ImageIcon("image/7.gif");
    icon8 = new ImageIcon("image/8.gif");
    icon9 = new ImageIcon("image/9.gif");
    icon10 = new ImageIcon("image/10.gif");
    icon11 = new ImageIcon("image/11.gif");
    icon12 = new ImageIcon("image/12.gif");
    icon13 = new ImageIcon("image/13.gif");
    icon14 = new ImageIcon("image/14.gif");
    contentPane = (JPanel) this.getContentPane();
    for(int i=0,j=1;i<14||j<15;i++,j++)
    {
            s[i]="头像"+j;
    }
    name.setEnabled(true);
    name.setFont(new java.awt.Font("Dialog", 0, 13));
    name.setBorder(BorderFactory.createEtchedBorder());
    name.setHorizontalAlignment(SwingConstants.CENTER);
    name.setText("呢称:");
    name.setBounds(new Rectangle(156, 27, 45, 25));
    contentPane.setLayout(null);
    this.setSize(new Dimension(448, 357));
    this.setTitle("翰海林注册--按alt+ctrl提交");
    this.setLocation(200,200);
    namearea.setFont(new java.awt.Font("Dialog", 0, 13));
    namearea.setBorder(BorderFactory.createEtchedBorder());
    namearea.setBounds(new Rectangle(200, 27, 100, 25));
    password.setFont(new java.awt.Font("Dialog", 0, 13));
    password.setBorder(BorderFactory.createEtchedBorder());
    password.setHorizontalAlignment(SwingConstants.CENTER);
    password.setText("密码:");
    password.setBounds(new Rectangle(156, 61, 45, 25));
    passwordarea.setFont(new java.awt.Font("Dialog", 0, 13));
    passwordarea.setBorder(BorderFactory.createEtchedBorder());
    passwordarea.setBounds(new Rectangle(200, 61, 100, 25));
    jp1.setBorder(BorderFactory.createEtchedBorder());
    jp1.setHorizontalAlignment(SwingConstants.CENTER);
    jp1.setBounds(new Rectangle(8, 9, 135, 274));
    jp1.setIcon(icon);
    email.setBorder(BorderFactory.createEtchedBorder());
    email.setHorizontalAlignment(SwingConstants.CENTER);
    email.setFont(new java.awt.Font("Dialog", 0, 13));
    email.setText("邮箱:");
    email.setBounds(new Rectangle(156, 100, 45, 25));
    emailarea.setBorder(BorderFactory.createEtchedBorder());
    emailarea.setBounds(new Rectangle(200, 100, 130, 25));
    jp2.setBorder(BorderFactory.createEtchedBorder());
    jp2.setBounds(new Rectangle(346, 25, 91, 100));
    jp2.setText("你的头像");
    jp2.setHorizontalAlignment(SwingConstants.CENTER);
    jcb.setBounds(new Rectangle(346, 124, 91, 22));
    jcb.addItem(ss);
    for(int i=0;i<14;i++)
    {
                    jcb.addItem(s[i]);
        }
        jcb.addItemListener(new ItemListener()
        {
                public void itemStateChanged(ItemEvent e)
                {
                            if(e.getItem().toString().compareTo("头像1")==0)

                                        {jp2.setIcon(icon1);
                                        i = 1;
                                }
                            else if(e.getItem().toString().compareTo("头像2")==0)
                                {
                                        jp2.setIcon(icon2);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像3")==0)
                                {
                                        jp2.setIcon(icon3);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像4")==0)
                                {
                                        jp2.setIcon(icon4);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像5")==0)
                                {
                                        jp2.setIcon(icon5);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像6")==0)
                                {
                                        jp2.setIcon(icon6);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像7")==0)
                                {
                                        jp2.setIcon(icon7);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像8")==0)
                                {
                                        jp2.setIcon(icon8);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像9")==0)
                                {
                                        jp2.setIcon(icon9);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像10")==0)
                                {
                                        jp2.setIcon(icon10);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像11")==0)
                                {
                                        jp2.setIcon(icon11);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像12")==0)
                                {
                                        jp2.setIcon(icon12);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像13")==0)
                                {
                                        jp2.setIcon(icon13);
                                        i = 1;
                                }
                                else if(e.getItem().toString().compareTo("头像14")==0)
                                {
                                        jp2.setIcon(icon14);
                                        i = 1;
                                }
                                else
                                {
                                        jp2.setIcon(null);
                                        i =0;
                                }
                }
        });
    zl.setBounds(new Rectangle(150, 165, 289, 118));
    ok.setBounds(new Rectangle(180, 290, 70, 30));
    jp1.addMouseListener(new MouseAdapter()
       {
          public void mouseClicked(MouseEvent e)        
    		{
    		Runtime r=Runtime.getRuntime();
    		try{
    			r.exec("explorer http://172.16.140.59");
    			}
    		catch(Exception ev){}
    		}
    	});
    cance.setBounds(new Rectangle(250, 290, 70, 30));
    contentPane.add(password, null);
    contentPane.add(passwordarea, null);
    contentPane.add(name, null);
    contentPane.add(namearea, null);
    contentPane.add(jp1, null);
    contentPane.add(email, null);
    contentPane.add(emailarea, null);
    contentPane.add(jp2, null);
    contentPane.add(jcb, null);

⌨️ 快捷键说明

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