📄 editdepinfo.java
字号:
package employee;
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import javax.swing.*;
public class EditDepInfo extends DepInfo {
String dName_str = "";
public EditDepInfo() {
this.setTitle("修改部门信息");
this.setResizable(false);
dDid.setEditable(false);
dName.setEditable(false);
dName.setText("请查询部门名称");
dManager.setEditable(false);
dManagerphone.setEditable(false);
//设置运行位置,使对话框居中
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation( (int) (screenSize.width - 400) / 2 ,
(int) (screenSize.height - 300) / 2 +45);
}
public void downInit(){
searchInfo.setText("部门名称查询");
searchInfo.setFont(new Font("Dialog",0,12));
downPanel.add(searchInfo);
modifyInfo.setText("修改");
modifyInfo.setFont(new Font("Dialog",0,12));
downPanel.add(modifyInfo);
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);
searchInfo.setEnabled(true);
modifyInfo.setEnabled(false);
clearInfo.setEnabled(true);
eixtInfo.setEnabled(true);
//添加事件侦听
searchInfo.addActionListener(this);
modifyInfo.addActionListener(this);
clearInfo.addActionListener(this);
eixtInfo.addActionListener(this);
}
/**
* 事件处理
*/
public void actionPerformed(ActionEvent e) {
Object obj = e.getSource();
String[] s = new String[3];
if (obj == eixtInfo) { //退出
this.dispose();
}
else if (obj == modifyInfo) { //修改
DepBean modifyDep = new DepBean();
modifyDep.depModify(dDid.getText(), dName.getText(), dManager.getText(), dManagerphone.getText());
modifyDep.depSearch(dName.getText());
s = modifyDep.depSearch(dName_str);
dDid.setText(s[0]);
dManager.setText(s[1]);
dManagerphone.setText(s[2]);
}
else if (obj == clearInfo) { //清空
setNull();
dName.setText("请查询部门名称");
}
else if (obj == searchInfo) { //部门名称查询
DepInfoSearchDname disd = new DepInfoSearchDname(this);
disd.pack();
disd.setVisible(true);
dName_str = disd.getDname();
DepBean searchDep = new DepBean();
s = searchDep.depSearch(dName_str);
if(s == null){
JOptionPane.showMessageDialog(null, "记录不存在!");
dDid.setText("");
dName.setText("请查询部门名称");
dManager.setText("");
dManagerphone.setText("");
dName.setEditable(false);
dManager.setEditable(false);
dManagerphone.setEditable(false);
modifyInfo.setEnabled(false);
return;
}
else{
dDid.setText(s[0]);
dName.setText(dName_str);
dManager.setText(s[1]);
dManagerphone.setText(s[2]);
dName.setEditable(true);
dManager.setEditable(true);
dManagerphone.setEditable(true);
modifyInfo.setEnabled(true);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -