📄 addricgz.java
字号:
package soft1;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import soft1Method.*;
import java.sql.SQLException;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
public class AddRicgz extends JDialog {
JPanel panel1 = new JPanel();
XYLayout xYLayout1 = new XYLayout();
XYLayout xYLayout2 = new XYLayout();
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton();
JTextField jTextField1 = new JTextField();
JButton jButton2 = new JButton();
Dataset2 dt=new Dataset2();
public AddRicgz(Frame owner, String title, boolean modal) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit();
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public AddRicgz() {
this(new Frame(), "AddRicgz", true);
}
private void jbInit() throws Exception {
panel1.setLayout(xYLayout2);
this.getContentPane().setLayout(xYLayout1);
this.setTitle("添加种类");
this.setUndecorated(true);
jLabel1.setText("请输入要添加的种类:");
jButton2.addActionListener(new AddRicgz_jButton2_actionAdapter(this));
this.getContentPane().add(panel1, new XYConstraints(6, 8, 169, 105));
jButton1.setText("jButton1");
jButton1.addActionListener(new AddRicgz_jButton1_actionAdapter(this));
jButton2.setText("确定");
this.getContentPane().setBackground(SystemColor.controlShadow);
panel1.add(jLabel1, new XYConstraints(0, 7, 134, 25));
panel1.add(jButton1, new XYConstraints(147, 0, 22, 18));
panel1.add(jTextField1, new XYConstraints(11, 33, 140, 33));
panel1.add(jButton2, new XYConstraints(38, 74, 88, 27));
xYLayout1.setWidth(182);
xYLayout1.setHeight(120);
}
public void jButton1_actionPerformed(ActionEvent e) {
this.setVisible(false);
}
public void jButton2_actionPerformed(ActionEvent e) throws
ClassNotFoundException, SQLException {
String ss="Select * from WorkPadSort where Sort ='"+jTextField1.getText()+"'";
dt.Rs(ss);
if(jTextField1.getText().equals("")){
JOptionPane.showMessageDialog(this,"请输入内容","提示",JOptionPane.PLAIN_MESSAGE);
}
else{
if(dt.Rs(ss).next()){
JOptionPane.showMessageDialog(this,"已有相同类型","提示",JOptionPane.PLAIN_MESSAGE);
}
else{
String s="insert into WorkPadSort(Sort) values('"+jTextField1.getText()+"')";
dt.Update(s);
JOptionPane.showMessageDialog(this,"插入成功!","提示",JOptionPane.PLAIN_MESSAGE);
this.setVisible(false);
}}
}
}
class AddRicgz_jButton2_actionAdapter implements ActionListener {
private AddRicgz adaptee;
AddRicgz_jButton2_actionAdapter(AddRicgz adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
try {
adaptee.jButton2_actionPerformed(e);
} catch (SQLException ex) {
} catch (ClassNotFoundException ex) {
}
}
}
class AddRicgz_jButton1_actionAdapter implements ActionListener {
private AddRicgz adaptee;
AddRicgz_jButton1_actionAdapter(AddRicgz adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -