?? goodmodiform.java
字號:
package good;
import java.awt.*;
import java.awt.event.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.*;
public class GoodModiForm extends JFrame implements ActionListener{
private static final int CENTER = 0;
/**
* @param args
*/
Goods goods=new Goods();
public GoodModiForm()
{
DataConn Con = new DataConn();
Container container=this.getContentPane();
JPanel staticPanel=new JPanel(new GridLayout(4,2),true);
JPanel staticPanel1=new JPanel(new FlowLayout(),true);
JLabel codeL= new JLabel("貨物編號",CENTER);
JLabel nameL= new JLabel("貨物名稱",CENTER);
JLabel numberL= new JLabel("貨物數量",CENTER);
JLabel priceL= new JLabel("貨物價格",CENTER);
final JComboBox codeField=new JComboBox(goods.GetAllGoodId());
final JTextField nameField=new JTextField("",10);
final JTextField numberField=new JTextField("",10);
final JTextField priceField=new JTextField("",10);
JButton okButton=new JButton("確定");
JButton cancelButton=new JButton("取消");
//jj.getContentPane().add(container);
container.add(staticPanel,"Center");
container.add(staticPanel1,"South");
staticPanel.add(codeL);
staticPanel.add(codeField);
staticPanel.add(nameL);
staticPanel.add(nameField);
staticPanel.add(numberL);
staticPanel.add(numberField);
staticPanel.add(priceL);
staticPanel.add(priceField);
staticPanel1.add(okButton);
staticPanel1.add(cancelButton);
okButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
try {
if (nameField.getText().trim().length()>0 && numberField.getText().trim().length()>0 && priceField.getText().trim().length()>0 )
{
goods.setGoodId(codeField.getSelectedItem().toString().trim());
goods.setGoodName(nameField.getText());
goods.setGoodNumber(numberField.getText());
goods.setGoodPrice(priceField.getText());
if (goods.goodsModi())
{
JOptionPane.showConfirmDialog(GoodModiForm.this,"修改成功!","提示",0);
}
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
};
});
cancelButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
dispose();
}
});
codeField.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
goods.setGoodId(codeField.getSelectedItem().toString().trim());
goods.resultData();
nameField.setText(goods.getGoodName().trim()) ;
numberField.setText(goods.getGoodNumber().trim());
priceField.setText(goods.getGoodPrice().trim()) ;
}
});this.setTitle("修改貨物信息");
this.setSize(300,300);
this.setBounds(0,50,310,210);
this.show();
}
public void actionPerformed(ActionEvent actionEvent) {
}
public static void main(String[] args)
{
GoodModiForm gg=new GoodModiForm();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -