📄 adddepinfo.java
字号:
package employee;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
/**
* 部门信息管理模块
* 添加新的部门信息
*/
public class AddDepInfo extends DepInfo{
public AddDepInfo() {
this.setTitle("添加部门信息");
this.setResizable(false);
dDid.setEditable(false);
dName.setEditable(true);
dManager.setEditable(true);
dManagerphone.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) { //添加
dName.setEditable(false);
dManager.setEditable(false);
dManagerphone.setEditable(false);
addInfo.setEnabled(false);
clearInfo.setEnabled(false);
eixtInfo.setEnabled(false);
DepBean addDep = new DepBean();
addDep.depAdd(dName.getText(), dManager.getText(), dManagerphone.getText());
this.dispose();
AddDepInfo adi = new AddDepInfo();
adi.downInit();
adi.pack();
adi.setVisible(true);
this.dispose();
}
else if (obj == clearInfo) { //清空
setNull();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -