imanufactureraddform.java
来自「一个货物管理系」· Java 代码 · 共 122 行
JAVA
122 行
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.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class ImanufacturerAddForm extends JFrame implements ActionListener{
private static final int CENTER = 0;
/**
* @param args
*/
Imanufacturer imanufacturer=new Imanufacturer();
public ImanufacturerAddForm()
{
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 codeL= new JLabel("货物编号",CENTER);
JLabel nameL= new JLabel("厂商名称",CENTER);
JLabel phonenumberL= new JLabel("联系电话",CENTER);
JLabel addressL= new JLabel("地址",CENTER);
//final JTextField mnameField=new JTextField("",10);
final JTextField nameField=new JTextField("",10);
final JTextField phonenumberField=new JTextField("",10);
final JTextField addressField=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(phonenumberL);
staticPanel.add(phonenumberField);
staticPanel.add(addressL);
staticPanel.add(addressField);
staticPanel1.add(okButton);
staticPanel1.add(cancelButton);
{okButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
try {
if ( nameField.getText().trim().length()>0 && phonenumberField.getText().trim().length()>0 && addressField.getText().trim().length()>0 )
{
//goods.setGoodId(codeField.getText());
imanufacturer.setManufName(nameField.getText());
imanufacturer.setManufPhonenumber(phonenumberField.getText());
imanufacturer.setManufAddress(addressField.getText());
if (imanufacturer.checkData()){
imanufacturer.ImanufacturerAdd();
if (JOptionPane.OK_OPTION!= JOptionPane.showConfirmDialog(ImanufacturerAddForm.this,"成功!是否继续添加?","提示",0))
{
dispose();
}
else
{
phonenumberField.setText("");
nameField.setText("");
addressField.setText("");
}
}
else
{
JOptionPane.showConfirmDialog(ImanufacturerAddForm.this,"该货物编号已经存在!","提示",0) ;
phonenumberField.setText("");
nameField.setText("");
addressField.setText("");;
}
}
else
{
JOptionPane.showConfirmDialog(ImanufacturerAddForm.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)
{
ImanufacturerAddForm gg=new ImanufacturerAddForm();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?