📄 addaction.java~18~
字号:
package informationsystem.gui;
import java.awt.event.*;
import informationsystem.gui.MainWindow;
import informationsystem.information.*;
public class AddAction
implements ActionListener {
public AddAction() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private MainWindow window;
public AddAction(MainWindow window) {
this.window = window;
}
/**
* Invoked when an action occurs.
*
* @param e ActionEvent
* @todo Implement this java.awt.event.ActionListener method
*/
public void actionPerformed(ActionEvent e) {
try {
if (this.window.jTextField2.getText().length() == 0) {
this.window.jTextPane1.setText("请输入硬盘容量!");
// 清空信息框
return;
}
if (this.window.jTextField3.getText().length() == 0) {
this.window.jTextPane1.setText("请输入生产产家!");
return;
}
if (this.window.jTextField4.getText().length() == 0) {
this.window.jTextPane1.setText("请输入硬盘适用类型!");
return;
}
if (this.window.jTextField5.getText().length() == 0) {
this.window.jTextPane1.setText("请输入硬盘接口类型!");
return;
}
if (HardDisk.addHardDisk(this.window.jTextField5.getText(),
this.window.jTextField2.getText(),
this.window.jTextField3.getText(),
this.window.jTextField4.getText(),
this.window.jTextField1.getText())) {
this.window.jTextPane1.setText("添加成功!");
}
else {
this.window.jTextPane1.setText("添加失败!");
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -