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

📄 add.java~1~

📁 中小学校园的教师
💻 JAVA~1~
字号:
package ui;import javax.swing.*;import java.awt.*;import com.borland.jbcl.layout.*;import java.awt.event.*;import java.sql.Connection;import java.sql.PreparedStatement;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class add extends JFrame {  JPanel jPanel1 = new JPanel();  XYLayout xYLayout1 = new XYLayout();  JPanel jPanel2 = new JPanel();  XYLayout xYLayout2 = new XYLayout();  JTextField jtfadrr = new JTextField();  JLabel jLabel1 = new JLabel();  JTextField jtfco = new JTextField();  JLabel jLabel2 = new JLabel();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  public add() {    try {      jbInit();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  void jbInit() throws Exception {    this.setSize(376, 218);    this.getContentPane().setLayout(xYLayout1);    jPanel2.setLayout(xYLayout2);    jLabel1.setText("地址");    jLabel2.setText("容量");    jtfadrr.setText("");    jtfco.setText("");    jButton1.setText("取消");    jButton1.addActionListener(new add_jButton1_actionAdapter(this));    jButton2.setText("确定");    jButton2.addActionListener(new add_jButton2_actionAdapter(this));    this.getContentPane().setBackground(SystemColor.textHighlightText);    this.setLocale(java.util.Locale.getDefault());    this.getContentPane().add(jPanel1,  new XYConstraints(0, 0, -1, 300));    this.getContentPane().add(jPanel2,      new XYConstraints(0, 0, 399, 301));    jPanel2.add(jLabel1, new XYConstraints(24, 39, 57, 32));    jPanel2.add(jLabel2,  new XYConstraints(194, 37, 49, 30));    jPanel2.add(jtfadrr, new XYConstraints(73, 42, 78, 27));    jPanel2.add(jtfco, new XYConstraints(241, 36, 81, 34));    jPanel2.add(jButton1, new XYConstraints(93, 154, -1, -1));    jPanel2.add(jButton2, new XYConstraints(210, 154, -1, -1));  }  void jButton1_actionPerformed(ActionEvent e) {    this.dispose();  }  void jButton2_actionPerformed(ActionEvent e)  {String sql = null;    int co,ad;    try {      co = Integer.parseInt(jtfco.getText().trim()); //jtfco.getText().trim();       ad = Integer.parseInt(jtfadrr.getText().trim());   if(ClassroomVindicateFrame.flag)    {       sql =          "INSERT INTO dbo.classroom(classroom_site, classroom_size) VALUES (?,?)";    }    else    {        sql =        "UPDATE dbo.classroom SET classroom_site =?, classroom_size =? where classroom_id ="            +ClassroomVindicateFrame.statu;          //  System.out.println(ClassroomVindicateFrame.statu);    }    Connection con = null;    try{      con = DBConnection.getConnection();      PreparedStatement ps = con.prepareStatement(sql);      ps.setString(1, jtfco.getText());      ps.setString(2, jtfadrr.getText());      ps.executeUpdate();      closeP.close(ps);    }catch(Exception ex){      ex.printStackTrace();    }finally{      closeP.close(con);      this.dispose();    }    }    catch (NumberFormatException ex1)    {      JOptionPane.showMessageDialog(null,"两个框的内容都是数字!!!");    }   /* if(ClassroomVindicateFrame.flag)    {       sql =          "INSERT INTO dbo.classroom(classroom_site, classroom_size) VALUES (?,?)";    }    else    {        sql =        "UPDATE dbo.classroom SET classroom_site =?, classroom_size =? where classroom_id ="            +ClassroomVindicateFrame.statu;            System.out.println(ClassroomVindicateFrame.statu);    }    Connection con = null;    try{      con = DBConnection.getConnection();      PreparedStatement ps = con.prepareStatement(sql);      ps.setString(1, jtfco.getText());      ps.setString(2, jtfadrr.getText());      ps.executeUpdate();      closeP.close(ps);    }catch(Exception ex){      ex.printStackTrace();    }finally{      closeP.close(con);      this.dispose();    }*/  }}class add_jButton1_actionAdapter implements java.awt.event.ActionListener {  add adaptee;  add_jButton1_actionAdapter(add adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class add_jButton2_actionAdapter implements java.awt.event.ActionListener {  add adaptee;  add_jButton2_actionAdapter(add adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

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