📄 viewaction.java
字号:
package informationsystem.gui;
import java.awt.event.*;
import informationsystem.gui.MainWindow;
import informationsystem.database.DBHandler;
import informationsystem.information.HardDisk;
public class ViewAction
implements ActionListener {
public ViewAction() {
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private MainWindow window;
private DBHandler db = new DBHandler();
public ViewAction(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 {
String number = this.window.jTextField1.getText();
// String capacity = this.window.jTextField2.getText(); //*****************************
//以下是通过输入价格来查询硬盘的相关信息
if (db.validate(number)) { // 增加了&&db.validate(capacity)
HardDisk HardDisk = new HardDisk(number);
// Student st = new Student(capacity); //*****************增加
this.window.jTextField5.setText(HardDisk.getApplyType());
this.window.jTextField2.setText(HardDisk.getCapacity()); //*******************
this.window.jTextField3.setText(HardDisk.getFactory());
this.window.jTextField4.setText(HardDisk.getBelongInterface());
this.window.jTextField1.setText(HardDisk.getPrice());
this.window.jTextPane1.setText(HardDisk.getPrice()+","+HardDisk.getCapacity()+","
+HardDisk.getFactory()+","
+HardDisk.getBelongInterface()+","+HardDisk.getApplyType()
+"—————:"+HardDisk.getDetailContent());
//************************************************
/*//以下是使硬盘的具体信息在ta区域内显示
Object eo=e.getSource();
if (eo==this.window.jButton6)
this.window.ta.setText(student.getDetailContent());
////以上是使硬盘的具体信息在ta区域内显示*/
}
else {
this.window.jTextField1.setText("");
this.window.jTextPane1.setText("数据库中没有您查询的价格和容量!");
this.window.ta.setText("数据库中没有您查询的价格和容量!");
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
private void jbInit() throws Exception {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -