addappinfo.java

来自「完整的JAVA工程」· Java 代码 · 共 79 行

JAVA
79
字号
package employee;

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

/**
 * 职务信息管理模块
 * 添加新的职务信息
 */
public class AddAppInfo extends AppInfo{

	AppBean getAaid = new AppBean();

	public AddAppInfo() {
		this.setTitle("添加部门信息");
		this.setResizable(false);

		aAid.setEditable(false);
		aName.setEditable(true);

		//设置运行位置,使对话框居中
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		this.setLocation( (int) (screenSize.width - 400) / 2 ,
						(int) (screenSize.height - 300) / 2 +45);
	}

	public void downInit(){
		addInfo.setText("添加");
		addInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(addInfo);
		clearInfo.setText("清空");
		clearInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(clearInfo);
		eixtInfo.setText("退出");
		eixtInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(eixtInfo);

		this.contentPane.add(downPanel,BorderLayout.SOUTH);

		//添加事件侦听
		addInfo.addActionListener(this);
		clearInfo.addActionListener(this);
		eixtInfo.addActionListener(this);
	}

	/**
	 * 事件处理
	 */
	public void actionPerformed(ActionEvent e) {
		Object obj = e.getSource();
		if (obj == eixtInfo) { //退出
			this.dispose();
		}
		else if (obj == addInfo) { //添加
			aAid.setEnabled(false);
			aName.setEditable(false);

			addInfo.setEnabled(false);
			clearInfo.setEnabled(false);
			eixtInfo.setEnabled(false);

			AppBean addApp = new AppBean();
			addApp.appAdd(aName.getText());
			
			this.dispose();

			AddAppInfo aai = new AddAppInfo();
			aai.downInit();
			aai.pack();
			aai.setVisible(true);

			this.dispose();
		}
		else if (obj == clearInfo) { //清空
			setNull();
		}
	}
}

⌨️ 快捷键说明

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