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

📄 empinfo.java

📁 完整的JAVA工程
💻 JAVA
字号:
package employee;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import javax.swing.border.*;
import javax.swing.filechooser.*;

/**
 * 职工信息综合管理类
 * 提供主界面,供其他类继承
 */
public class EmpInfo extends JFrame implements ActionListener{
	Container contentPane;
	JTabbedPane TP=new JTabbedPane();
	JPanel P1 = new JPanel();
	JPanel upPanel = new JPanel();
	JPanel downPanel = new JPanel();
	JFileChooser fc;
	String fname=null;

	//框架的大小
	Dimension faceSize = new Dimension(500, 600);

	String []s4={"男","女"};
	String []s7={"博士","硕士","大学","大专","高中","中专"};
	String []s10={"党员","群众"};
	String []s11={"已婚","未婚"};
	String []s14={"是","否"};
	JLabel pic=new JLabel();
	JLabel jLabel1 = new JLabel("职工编号:");JLabel L1 = new JLabel("* (必填)");
	JLabel jLabel2 = new JLabel("职工密码:");
	JLabel jLabel3 = new JLabel("姓名:");JLabel L3 = new JLabel("*");
	JLabel jLabel4 = new JLabel("性别:");JLabel L4 = new JLabel("*");
	JLabel jLabel5 = new JLabel("民族:");JLabel L5 = new JLabel("例如:汉族");
	JLabel jLabel6 = new JLabel("籍贯:");JLabel L6 = new JLabel("例如:北京");
	JLabel jLabel7 = new JLabel("学历:");
	JLabel jLabel8 = new JLabel("专业:");
	JLabel jLabel9 = new JLabel("出生日期:");JLabel L9 = new JLabel("例如:1986/5/20");
	JLabel jLabel10 = new JLabel("政治面貌:");
	JLabel jLabel11 = new JLabel("婚姻状况:");
	JLabel jLabel12 = new JLabel("身份证号:");
	JLabel jLabel13 = new JLabel("户口所在地:");JLabel L13 = new JLabel("例如:北京市海淀区");
	JLabel jLabel14 = new JLabel("城镇户口:");
	JLabel jLabel15 = new JLabel("通讯地址:");
	JLabel jLabel16 = new JLabel("邮政编码:");
	JLabel jLabel17 = new JLabel("手机:");
	JLabel jLabel18 = new JLabel("联系电话:");JLabel L18 = new JLabel("例如:01069781234");
	JLabel jLabel19 = new JLabel("电子邮件:");
	JTextField eEid = new JTextField(14);
	JTextField ePassword = new JTextField(14);
	JTextField eName = new JTextField(10);
	JComboBox eSex = new JComboBox(s4);
	JTextField eNation = new JTextField(10);
	JTextField eRegion = new JTextField(10);
	JComboBox eEducation = new JComboBox(s7);
	JTextField eSpecialty = new JTextField(10);
	JTextField eBirthday = new JTextField(8);
	JComboBox eGstatus = new JComboBox(s10);
	JComboBox eMarriage = new JComboBox(s11);
	JTextField eIdcard = new JTextField(18);
	JTextField eHlocation = new JTextField(50);
	JComboBox eCityhk = new JComboBox(s14);
	JTextField eCaddress = new JTextField(50);
	JTextField ePostcode = new JTextField(6);
	JTextField eMobilephone = new JTextField(11);
	JTextField eHomephone = new JTextField(11);
	JTextField eEmail = new JTextField(50);
	JButton addpic=new JButton("选择照片");
	JButton searchInfo = new JButton();
	JButton addInfo = new JButton();
	JButton modifyInfo = new JButton();
	JButton deleteInfo = new JButton();
	JButton clearInfo = new JButton();
	JButton saveInfo = new JButton();
	JButton eixtInfo = new JButton();

	public EmpInfo() {
		//设置框架的大小
		this.setSize(faceSize);
		//设置标题
		this.setTitle("职工综合信息管理"); 
		this.setResizable(false);
		//设置程序图标
		this.setIconImage(getImage("icon.gif")); 

		try	{
			Init();
		}
		catch(Exception	e) {
			e.printStackTrace();
		}
	}

	public void Init() throws Exception {
		contentPane = this.getContentPane();
		contentPane.setLayout(new BorderLayout());

		//第一页布局
		P1.setLayout(null);

		//(x,y,长,宽)
		jLabel1.setBounds(20,20,70,40);eEid.setBounds(100,30,90,20);L1.setBounds(200,30,90,20);
		jLabel2.setBounds(20,50,70,20);ePassword.setBounds(100,50,90,20);
		jLabel3.setBounds(20,70,70,20);eName.setBounds(100,70,90,20);L3.setBounds(200,70,90,20);
		pic.setBounds(310,20,120,150);addpic.setBounds(310,210,120,30);
		jLabel4.setBounds(20,80,70,40);eSex.setBounds(100,90,90,20);eSex.setEditable(false);L4.setBounds(200,90,90,20);
		jLabel5.setBounds(20,100,70,40);eNation.setBounds(100,110,90,20);L5.setBounds(200,110,90,20);
		jLabel6.setBounds(20,120,70,40);eRegion.setBounds(100,130,90,20);L6.setBounds(200,130,90,20);
		jLabel7.setBounds(20,140,70,40);eEducation.setBounds(100,150,90,20);eEducation.setEditable(false);
		jLabel8.setBounds(20,160,70,40);eSpecialty.setBounds(100,170,90,20);
		jLabel9.setBounds(20,180,70,40);eBirthday.setBounds(100,190,90,20);L9.setBounds(200,190,100,20);
		jLabel10.setBounds(20,200,70,40);eGstatus.setBounds(100,210,90,20);eGstatus.setEditable(false);
		jLabel11.setBounds(20,220,70,40);eMarriage.setBounds(100,230,90,20);eMarriage.setEditable(false);
		jLabel12.setBounds(20,240,90,40);eIdcard.setBounds(100,250,90,20);
		jLabel13.setBounds(20,260,90,40);eHlocation.setBounds(100,270,90,20);L13.setBounds(200,270,120,20);
		jLabel14.setBounds(20,280,90,40);eCityhk.setBounds(100,290,90,20);eCityhk.setEditable(false);
		jLabel15.setBounds(20,300,90,40);eCaddress.setBounds(100,310,90,20);
		jLabel16.setBounds(20,320,90,40);ePostcode.setBounds(100,330,90,20);
		jLabel17.setBounds(20,340,90,40);eMobilephone.setBounds(100,350,90,20);
		jLabel18.setBounds(20,360,90,40);eHomephone.setBounds(100,370,90,20);L18.setBounds(200,370,120,20);
		jLabel19.setBounds(20,380,90,40);eEmail.setBounds(100,390,90,20);
		addpic.addActionListener(this);
		pic.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
		P1.add(jLabel1);P1.add(eEid);P1.add(L1);
		P1.add(jLabel2);P1.add(ePassword);
		P1.add(jLabel3);P1.add(eName);P1.add(L3);
		P1.add(pic);P1.add(addpic);
		P1.add(jLabel4);P1.add(eSex);P1.add(L4);
		P1.add(jLabel5);P1.add(eNation);P1.add(L5);
		P1.add(jLabel6);P1.add(eRegion);P1.add(L6);
		P1.add(jLabel7);P1.add(eEducation);
		P1.add(jLabel8);P1.add(eSpecialty);
		P1.add(jLabel9);P1.add(eBirthday);P1.add(L9);
		P1.add(jLabel10);P1.add(eGstatus);
		P1.add(jLabel11);P1.add(eMarriage);
		P1.add(jLabel12);P1.add(eIdcard);
		P1.add(jLabel13);P1.add(eHlocation);P1.add(L13);
		P1.add(jLabel14);P1.add(eCityhk);
		P1.add(jLabel15);P1.add(eCaddress);
		P1.add(jLabel16);P1.add(ePostcode);
		P1.add(jLabel17);P1.add(eMobilephone);
		P1.add(jLabel18);P1.add(eHomephone);P1.add(L18);
		P1.add(jLabel19);P1.add(eEmail);
		
		contentPane.add(P1,BorderLayout.CENTER);

		eEid.setEditable(false);
		ePassword.setEditable(false);
		eName.setEditable(false);
		eSex.setEditable(false);
		eNation.setEditable(false);
		eRegion.setEditable(false);
		eEducation.setEditable(false);
		eSpecialty.setEditable(false);
		eBirthday.setEditable(false);
		eGstatus.setEditable(false);
		eMarriage.setEditable(false);
		eIdcard.setEditable(false);
		eHlocation.setEditable(false);
		eCityhk.setEditable(false);
		eCaddress.setEditable(false);
		ePostcode.setEditable(false);
		eMobilephone.setEditable(false);
		eHomephone.setEditable(false);
		eEmail.setEditable(false);	
	}
	
	/**
	 * 下部面板的布局
	 */
	public void downInit(){
		searchInfo.setText("查询");
		searchInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(searchInfo);
		addInfo.setText("添加");
		addInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(addInfo);
		modifyInfo.setText("修改");
		modifyInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(modifyInfo);
		deleteInfo.setText("删除");
		deleteInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(deleteInfo);
		saveInfo.setText("保存");
		saveInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(saveInfo);
		clearInfo.setText("清空");
		clearInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(clearInfo);
		eixtInfo.setText("退出");
		eixtInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(eixtInfo);

		contentPane.add(downPanel,BorderLayout.SOUTH);

		//添加事件侦听
		searchInfo.addActionListener(this);
		addInfo.addActionListener(this);
		modifyInfo.addActionListener(this);
		deleteInfo.addActionListener(this);
		saveInfo.addActionListener(this);
		clearInfo.addActionListener(this);
		eixtInfo.addActionListener(this);

		modifyInfo.setEnabled(false);
		deleteInfo.setEnabled(false);
		saveInfo.setEnabled(false);
		clearInfo.setEnabled(false);
	}

	/**
	 * 事件处理
	 */
	public void actionPerformed(ActionEvent e) {
		Object obj = e.getSource();
		if (obj == searchInfo) { //查询
		}
		else if (obj == addpic) { //添加照片
		}
		else if (obj == addInfo) { //添加
		}
		else if (obj == modifyInfo) { //修改
		}
		else if (obj == deleteInfo) { //删除
		}
		else if (obj == saveInfo) { //保存
		}
		else if (obj == clearInfo) { //清空
			setNull();
		}
		else if (obj == eixtInfo) { //退出
			this.dispose();
		}
	}

	/**
	 * 将文本框清空
	 */
	void setNull(){
		eEid.setText(null);
		ePassword.setText(null);
		eName.setText(null);
		eNation.setText(null);
		eRegion.setText(null);
		eSpecialty.setText(null);
		eBirthday.setText(null);
		eIdcard.setText(null);
		eHlocation.setText(null);
		eCaddress.setText(null);
		ePostcode.setText(null);
		eMobilephone.setText(null);
		eHomephone.setText(null);
		eEmail.setText(null);
	}

	/**
	 * 通过给定的文件名获得图像
	 */
	Image getImage(String filename) {
		URLClassLoader urlLoader = (URLClassLoader)this.getClass().
			getClassLoader();
		URL url = null;
		Image image = null;
		url = urlLoader.findResource(filename);
		image = Toolkit.getDefaultToolkit().getImage(url);
		MediaTracker mediatracker = new MediaTracker(this);
		try {
			mediatracker.addImage(image, 0);
			mediatracker.waitForID(0);
		}
		catch (InterruptedException _ex) {
			image = null;
		}
		if (mediatracker.isErrorID(0)) {
			image = null;
		}
		return image;
	}
	public static void main(String[] args){
		EmpInfo a=new EmpInfo();
		a.setVisible(true);
	}
}

⌨️ 快捷键说明

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