⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addkind.java

📁 一个个人信息管理系统
💻 JAVA
字号:
package soft1;

import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import soft1Method.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.sql.SQLException;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class AddKind extends JDialog {
    JPanel panel1 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JButton jButton1 = new JButton();
    XYLayout xYLayout1 = new XYLayout();
    XYLayout xYLayout2 = new XYLayout();
    JButton jButton2 = new JButton();

    public AddKind(Frame owner, String title, boolean modal) {
        super(owner, title, modal);
        try {
            setDefaultCloseOperation(DISPOSE_ON_CLOSE);
            jbInit();
            pack();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public AddKind() {
        this(new Frame(), "AddKind", true);
    }

    private void jbInit() throws Exception {
        panel1.setLayout(xYLayout2);
        this.getContentPane().setLayout(xYLayout1);
        this.setUndecorated(true);
        jLabel1.setText("请输入要添加的种类:");
        jButton1.setActionCommand("");
        jButton1.setText("确认");
        jButton1.addActionListener(new AddKind_jButton1_actionAdapter(this));
        xYLayout1.setWidth(189);
        xYLayout1.setHeight(110);
        this.getContentPane().setBackground(UIManager.getColor("Button.shadow"));
        jButton2.setText("*");
        jButton2.addActionListener(new AddKind_jButton2_actionAdapter(this));
        panel1.add(jButton1, new XYConstraints(43, 65, 84, 28));
        panel1.add(jTextField1, new XYConstraints(12, 27, 150, 30));
        panel1.add(jLabel1, new XYConstraints(6, 0, -1, 32));
        panel1.add(jButton2, new XYConstraints(157, 0, 22, 15));
        this.getContentPane().add(panel1, new XYConstraints(5, 4, 179, 99));

    }

    public void jButton1_actionPerformed(ActionEvent e) throws
            ClassNotFoundException, SQLException {
      Dataset2 dt=new Dataset2();
      String s="Select * from AddrKind where Kind ='"+jTextField1.getText()+"'";
      dt.Rs(s);
      if(jTextField1.getText().equals("")){
          JOptionPane.showMessageDialog(this,"请输入内容","提示",JOptionPane.PLAIN_MESSAGE);
      }
      else{
          if(dt.Rs(s).next()){
              JOptionPane.showMessageDialog(this,"已有相同类型","提示",JOptionPane.PLAIN_MESSAGE);
          }
          else{
              String ss="insert into AddrKind(Kind)values ('"+jTextField1.getText()+"')";
              dt.Update(ss);
              JOptionPane.showMessageDialog(this,"插入成功!","提示",JOptionPane.PLAIN_MESSAGE);
              this.setVisible(false);
          }}


    }

    public void jButton2_actionPerformed(ActionEvent e) {
    this.setVisible(false);
    }
}


class AddKind_jButton2_actionAdapter implements ActionListener {
    private AddKind adaptee;
    AddKind_jButton2_actionAdapter(AddKind adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}


class AddKind_jButton1_actionAdapter implements ActionListener {
    private AddKind adaptee;
    AddKind_jButton1_actionAdapter(AddKind adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        try {
            adaptee.jButton1_actionPerformed(e);
        } catch (SQLException ex) {
        } catch (ClassNotFoundException ex) {
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -