?? zgview.java~14~
字號(hào):
package zcgl;
import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ZgView extends JFrame {
public ZgView() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
jPanel1.setBorder(BorderFactory.createEtchedBorder());
jPanel1.setBounds(new Rectangle(46, 32, 313, 239));
jPanel1.setLayout(null);
btnAdd.setBounds(new Rectangle(69, 288, 90, 38));
btnAdd.setText("添加");
btnAdd.addActionListener(new ZgView_btnAdd_actionAdapter(this));
btnDel.setBounds(new Rectangle(170, 287, 97, 38));
btnDel.setText("刪除");
btnDel.addActionListener(new ZgView_btnDel_actionAdapter(this));
btnModify.setBounds(new Rectangle(277, 289, 89, 38));
btnModify.setText("修改");
btnModify.addActionListener(new ZgView_btnModify_actionAdapter(this));
this.getContentPane().add(jPanel1);
this.getContentPane().add(btnAdd);
this.getContentPane().add(btnDel);
this.getContentPane().add(btnModify);
txtZgId.setBounds(new Rectangle(101, 39, 111, 23));
jLabel2.setText("姓名");
jLabel2.setBounds(new Rectangle(45, 73, 45, 25));
txtZgName.setBounds(new Rectangle(101, 73, 110, 21));
jLabel3.setText("工位");
jLabel3.setBounds(new Rectangle(45, 104, 31, 23));
txtZgwork.setBounds(new Rectangle(101, 105, 111, 23));
jLabel4.setText("備注");
jLabel4.setBounds(new Rectangle(45, 145, 31, 19));
txaContext.setBorder(BorderFactory.createEtchedBorder());
txaContext.setBounds(new Rectangle(101, 137, 181, 87));
jPanel1.add(jLabel1);
jPanel1.add(txtZgId);
jPanel1.add(jLabel2);
jPanel1.add(txtZgName);
jPanel1.add(txtZgwork);
jPanel1.add(jLabel3);
jPanel1.add(jLabel4);
jPanel1.add(txaContext);
jLabel1.setText("職工號(hào)");
jLabel1.setBounds(new Rectangle(45, 36, 59, 33));
}
JPanel jPanel1 = new JPanel();
JLabel jLabel1 = new JLabel();
JTextField txtZgId = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField txtZgName = new JTextField();
JLabel jLabel3 = new JLabel();
JTextField txtZgwork = new JTextField();
JLabel jLabel4 = new JLabel();
JTextArea txaContext = new JTextArea();
JButton btnAdd = new JButton();
JButton btnDel = new JButton();
JButton btnModify = new JButton();
public void btnAdd_actionPerformed(ActionEvent e) {
ZgBean bean = new ZgBean();
bean.setZgId(Integer.parseInt(txtZgId.getText()));
bean.setZgName(txtZgName.getText());
bean.setZgwork(txtZgwork.getText());
bean.setZgContext(txaContext.getText());
if (bean.insert()){
JOptionPane.showMessageDialog(this, "插入成功!");
}
else {
JOptionPane.showMessageDialog(this, "插入失?。?quot;);
}
}
public void btnDel_actionPerformed(ActionEvent e) {
ZgBean bean = new ZgBean();
bean.setZgId(Integer.parseInt(txtZgId.getText()));
if (bean.isNull()) {
JOptionPane.showMessageDialog(this, "沒有此記錄!");
return;
}
if (bean.del())
JOptionPane.showMessageDialog(this, "刪除成功!");
else
JOptionPane.showMessageDialog(this, "刪除失敗!");
}
public void btnModify_actionPerformed(ActionEvent e) {
ZgBean bean = new ZgBean();
bean.setZgId(Integer.parseInt(txtZgId.getText()));
if (bean.isNull()) {
JOptionPane.showMessageDialog(this, "沒有此記錄!");
return;
}
bean.setZgName(txtZgName.getText());
bean.setZgwork(txtZgwork.getText());
bean.setZgContext(txaContext.getText());
if (bean.modify())
JOptionPane.showMessageDialog(this, "修改成功!");
else
JOptionPane.showMessageDialog(this, "修改失?。?quot;);
}
}
class ZgView_btnModify_actionAdapter implements ActionListener {
private ZgView adaptee;
ZgView_btnModify_actionAdapter(ZgView adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnModify_actionPerformed(e);
}
}
class ZgView_btnDel_actionAdapter implements ActionListener {
private ZgView adaptee;
ZgView_btnDel_actionAdapter(ZgView adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnDel_actionPerformed(e);
}
}
class ZgView_btnAdd_actionAdapter implements ActionListener {
private ZgView adaptee;
ZgView_btnAdd_actionAdapter(ZgView adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.btnAdd_actionPerformed(e);
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -