📄 addtrainfo.java
字号:
package employee;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
/**
* 培训信息管理模块
* 添加新的培训信息
*/
public class AddTraInfo extends TraInfo{
TraBean getTtid = new TraBean();
public AddTraInfo() {
this.setTitle("添加培训信息");
this.setResizable(false);
tTid.setEditable(false);
tName.setEditable(true);
tContent.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) { //添加
tTid.setEnabled(false);
tName.setEditable(false);
tContent.setEditable(false);
addInfo.setEnabled(false);
clearInfo.setEnabled(false);
eixtInfo.setEnabled(false);
TraBean addTra = new TraBean();
addTra.traAdd(tName.getText(), tContent.getText());
this.dispose();
AddTraInfo ati = new AddTraInfo();
ati.downInit();
ati.pack();
ati.setVisible(true);
this.dispose();
}
else if (obj == clearInfo) { //清空
setNull();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -