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

📄 infomsgbox.java

📁 实现多人即时聊天
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class InfoMsgBox extends JFrame{


	 private String Job,PassWord,EMail,Tel;
	 ClientFrame clientframe;
	 User MyNewInfo;

/*******************************以下组件*******************************************/
	 private JLabel labGYJob=new JLabel("  职位  ");
	 private JTextField txtGYJob=new JTextField();	
	 private JLabel labGYPassWord=new JLabel("  密码  ");
	 private JTextField txtGYPassWord=new JTextField();
	 private JLabel labGYEMail=new JLabel("  邮箱  ");
	 private JTextField txtGYEMail=new JTextField();
	 private JLabel labGYTel=new JLabel("  电话  ");
	 private JTextField txtGYTel=new JTextField();
	  
	 JButton btnOk=new JButton("确定");
	 JButton btnCancel=new JButton("取消");	 
/*******************************以上组件*******************************************/
	
	public InfoMsgBox(ClientFrame clientframe){	
	
		this.clientframe=clientframe;


		MyNewInfo=this.clientframe.getMyself();

//txtGYJob.setText(MyNewInfo.getJob()+"                          ");
//txtGYPassWord.setText(MyNewInfo.getPassword()+"                          ");
//txtGYEMail.setText(MyNewInfo.getEMail()+"                                               ");
//txtGYTel.setText(MyNewInfo.getTel()+"                          ");

	    	//面板p中显示雇员信息
		
		JPanel p=new JPanel();
		p.setBorder(BorderFactory.createLoweredBevelBorder());
		p.setLayout(new GridBagLayout());

			
		LayoutUtil.add(p,labGYJob,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,0,1,1);
		LayoutUtil.add(p,txtGYJob,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,1,0,1,1);

		LayoutUtil.add(p,labGYPassWord,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,2,0,1,1);
		LayoutUtil.add(p,txtGYPassWord,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,3,0,1,1);
			
		LayoutUtil.add(p,labGYEMail,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,1,1,1);
		LayoutUtil.add(p,txtGYEMail,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,1,1,1,1);

		LayoutUtil.add(p,labGYTel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,2,1,1,1);
		LayoutUtil.add(p,txtGYTel,GridBagConstraints.HORIZONTAL,GridBagConstraints.CENTER,1,0,3,1,1,1);

		getContentPane().add(p,BorderLayout.CENTER);	
		
		//面板ap中显示2个按钮
		JPanel ap=new JPanel();
		ap.setLayout(new GridBagLayout());

		//LayoutUtil.add(ap,new JLabel(),GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,1,1,1);
	
		LayoutUtil.add(ap,btnOk,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,0,2,2,1);

		LayoutUtil.add(ap,btnCancel,GridBagConstraints.NONE,GridBagConstraints.CENTER,0,0,2,2,2,1);

		getContentPane().add(ap,BorderLayout.SOUTH);


		btnOk.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){

				User MyNewInfo=InfoMsgBox.this.clientframe.getMyself();

				Job=txtGYJob.getText().trim();
				PassWord=txtGYPassWord.getText().trim();
				EMail=txtGYEMail.getText().trim();
				Tel=txtGYTel.getText().trim();

			if(Job.equals("")||PassWord.equals("")||EMail.equals("")||Tel.equals("")){
				JOptionPane.showMessageDialog(InfoMsgBox.this,
						"User infomation is empty!",
						"Error",
						JOptionPane.ERROR_MESSAGE);
					return;
			}



				MyNewInfo.setJob(Job);
				MyNewInfo.setTel(Tel);
				MyNewInfo.setEMail(EMail);
				MyNewInfo.setPassword(PassWord);

System.out.println("UserInfo 已经读出 ");
System.out.println("UserInfo 已经读出 "+MyNewInfo.getJob());
System.out.println("UserInfo 已经读出 "+MyNewInfo.getTel());
System.out.println("UserInfo 已经读出 "+MyNewInfo.getEMail());
System.out.println("UserInfo 已经读出 "+MyNewInfo.getPassword());

				InfoMsgBox.this.clientframe.send(MyNewInfo);

			}

		});

		btnCancel.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				InfoMsgBox.this.dispose();
			}

		});

/*
		addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent e){
				InfoMsgBox.this.setVisible(false);				
			}//public void windowClosing(WindowEvent e)
		});//addWindowListener(new WindowAdapter()
*/

		setSize(350,150);
		setResizable(false);

	}//public InfoMsgBox(ClientFrame clientframe)
		



	public static void main(String args[]) {
     //InfoMsgBox window = new InfoMsgBox();
		//window.setSize(350,150);
		//window.show();
    }
}

⌨️ 快捷键说明

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