?? employeeaddform.java
字號:
package good;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class EmployeeAddform extends JFrame implements ActionListener{
private static final int CENTER = 0;
/**
* @param args
*/
Employee employee=new Employee();
public EmployeeAddform()
{
DataConn Con = new DataConn();
Container container=this.getContentPane();
JPanel staticPanel=new JPanel(new GridLayout(3,2),true);
JPanel staticPanel1=new JPanel(new FlowLayout(),true);
JLabel idL= new JLabel("雇員號",CENTER);
JLabel nameL= new JLabel("雇員姓名",CENTER);
JLabel numberL= new JLabel("聯系電話",CENTER);
//JLabel priceL= new JLabel("貨物價格",CENTER);
final JTextField idField=new JTextField("",10);
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(idL);
staticPanel.add(idField);
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 ( idField.getText().trim().length()>0 && nameField.getText().trim().length()>0 && numberField.getText().trim().length()>0 )
{
employee.setEmployeeId(idField.getText());
employee.setEmployeeName(nameField.getText());
employee.setEmployeeNumber(numberField.getText());
//employee.employeeAdd();}
if (employee.checkData()){
employee.employeeAdd();
if (JOptionPane.OK_OPTION!= JOptionPane.showConfirmDialog(EmployeeAddform.this,"成功!是否繼續添加?","提示",0))
{
dispose();
}
else
{
nameField.setText("");
numberField.setText("");
idField.setText("");
}
}
else
{
JOptionPane.showConfirmDialog(EmployeeAddform.this,"雇員已經存在!","提示",0);
nameField.setText("");
numberField.setText("");
idField.setText("");
}
}
else
{
JOptionPane.showConfirmDialog(EmployeeAddform.this,"請輸入完整信息!!","提示",0);
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
};
});
cancelButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
dispose();
}
});
this.setTitle("添加雇員");
this.setSize(300,300);
this.setBounds(0,50,310,200);
this.show();
}
public void actionPerformed(ActionEvent actionEvent) {
}
public static void main(String[] args)
{
EmployeeAddform gg=new EmployeeAddform();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -