?? updateaction.java~37~
字號(hào):
package informationsystem.gui;
import java.awt.event.*;
import java.sql.*;
import informationsystem.gui.MainWindow;
import informationsystem.information.HardDisk;
import informationsystem.information.HardDisk;
public class UpdateAction
implements ActionListener {
private MainWindow window;
public UpdateAction(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.jTextField1.getText().length() == 0) {
this.window.jTextPane1.setText("不能修改,請(qǐng)先輸入價(jià)格!");
}
else {
String number = this.window.jTextField1.getText();
HardDisk theHardDisk = new HardDisk(number);
if (theHardDisk.getBelongInterface().equals("") &&
theHardDisk.getFactory().equals("") &&
theHardDisk.getCapacity().equals("")&&theHardDisk.getPrice().equals("")) {
this.window.jTextPane1.setText("該價(jià)格不存在");
return;
}
//this.window.jTextField5.setText(this.window.jTextField1.getText());//*******************
if (this.window.jTextField2.getText().length() != 0) {
theHardDisk.setCapacity(this.window.jTextField2.getText()); // 更新硬盤(pán)的容量;
}
if (this.window.jTextField3.getText().length() != 0) {
theHardDisk.setFactory(this.window.jTextField3.getText()); // 更新硬盤(pán)的產(chǎn)家;
}
if (this.window.jTextField4.getText().length() != 0) {
theHardDisk.setInterfaceType(this.window.jTextField4.getText()); // 更新硬盤(pán)的接口類(lèi)型;**************
}
//////////////////////////2007-10-07
if (this.window.jTextField5.getText().length() != 0) {
theHardDisk.setApplyType(this.window.jTextField5.getText()); // 更新硬盤(pán)的接口類(lèi)型;**************
}
//////////////////////////
if (this.window.jTextField2.getText().length() == 0 &&
this.window.jTextField3.getText().length() == 0 &&
this.window.jTextField4.getText().length() == 0) {
this.window.jTextPane1.setText("請(qǐng)輸入修改的數(shù)據(jù)");
}
else {
if (theHardDisk.update()) {
this.window.jTextPane1.setText("記錄修改成功!");
}
else {
this.window.jTextPane1.setText("修改失敗,請(qǐng)重試!");
}
}
}
// 清空文本框
this.window.jTextField1.setText("");
this.window.jTextField2.setText("");
this.window.jTextField3.setText("");
this.window.jTextField4.setText("");
this.window.jTextField5.setText("");
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -