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

📄 addairjdialog.java

📁 大学课程 数据库的课程设计
💻 JAVA
字号:
package t;import java.awt.Dimension;import java.awt.Toolkit;import javax.swing.JOptionPane;import t.MyConnection;/** * * @author  Administrator */public class AddAirJDialog extends javax.swing.JDialog {        /** Creates new form AddAirJDialog */    public AddAirJDialog(java.awt.Frame parent, boolean modal) {        super(parent, modal);        initComponents();        LoadFrame.setLoc(this);    }        /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        jLabel1 = new javax.swing.JLabel();        jLabel2 = new javax.swing.JLabel();        jTextField1 = new javax.swing.JTextField();        jTextField2 = new javax.swing.JTextField();        jLabel3 = new javax.swing.JLabel();        jLabel4 = new javax.swing.JLabel();        jTextField3 = new javax.swing.JTextField();        jLabel5 = new javax.swing.JLabel();        jTextField4 = new javax.swing.JTextField();        jLabel6 = new javax.swing.JLabel();        jTextField5 = new javax.swing.JTextField();        jLabel7 = new javax.swing.JLabel();        jTextField6 = new javax.swing.JTextField();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);        jLabel1.setFont(new java.awt.Font("瀹嬩綋", 0, 24));        jLabel1.setText("\u6dfb\u52a0\u65b0\u7684\u822a\u73ed");        jLabel2.setText("\u822a\u73ed\u53f7");        jLabel3.setText("\u8d77\u98de\u65f6\u95f4");        jLabel4.setText("\u98de\u884c\u76ee\u7684\u5730");        jLabel5.setText("\u5546\u52a1\u8231\u7968\u4ef7");        jLabel6.setText("\u7ecf\u6d4e\u4ed3\u7968\u4ef7");        jLabel7.setText("\u5ea7\u4f4d\u4e2a\u6570");        jButton1.setLabel("\u6dfb\u52a0");        jButton1.addMouseListener(new java.awt.event.MouseAdapter() {            public void mouseClicked(java.awt.event.MouseEvent evt) {                jButton1MouseClicked(evt);            }        });        jButton2.setLabel("\u53d6\u6d88");        jButton2.addMouseListener(new java.awt.event.MouseAdapter() {            public void mouseClicked(java.awt.event.MouseEvent evt) {                jButton2MouseClicked(evt);            }        });        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)            .add(layout.createSequentialGroup()                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)                    .add(layout.createSequentialGroup()                        .add(114, 114, 114)                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 152, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                    .add(layout.createSequentialGroup()                        .add(47, 47, 47)                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)                            .add(layout.createSequentialGroup()                                .add(jButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                                .add(81, 81, 81)                                .add(jButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 72, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                            .add(layout.createSequentialGroup()                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)                                    .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)                                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 59, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                                    .add(jLabel4)                                    .add(jLabel5)                                    .add(jLabel6)                                    .add(jLabel7))                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)                                    .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 95, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                                    .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 132, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 90, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jTextField5)                                        .add(org.jdesktop.layout.GroupLayout.LEADING, jTextField4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE))                                    .add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 42, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))))                .addContainerGap(115, Short.MAX_VALUE))        );        layout.setVerticalGroup(            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)            .add(layout.createSequentialGroup()                .addContainerGap()                .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .add(18, 18, 18)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)                    .add(jTextField2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .add(18, 18, 18)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel4)                    .add(jTextField3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .add(18, 18, 18)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel5)                    .add(jTextField4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel6)                    .add(jTextField5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jLabel7)                    .add(jTextField6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))                .add(18, 18, 18)                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)                    .add(jButton1)                    .add(jButton2))                .addContainerGap(33, Short.MAX_VALUE))        );        pack();    }// </editor-fold>//GEN-END:initComponentsprivate void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked    // TODO add your handling code here:    String s1="";    String s2="";    String s3="";    String s4="";    String s5="";    int n;    s1=jTextField1.getText();    s2=jTextField2.getText();    s3=jTextField3.getText();    s4=jTextField4.getText();    s5=jTextField5.getText();    //n=jTextField6.getText();    n=Integer.parseInt(jTextField6.getText());   // System.out.println(s1+s2+s3+s4+s5+n);    String s6="'"+s1+"'" + "," + "'"+s2+"'" + "," + "'"+s3+"'" + "," + n + "," +"'"+ s4+"'" +","+"'"+s5+"'";    String s7="";    MyConnection mc = new MyConnection();    mc.insetAirLine("航班班次表",s6);    for(int j=1;j<=n;j++)    {        s7="'"+s1+"'"+","+j+","+1;        mc.insetAirLine("机位信息表",s7);    }    mc.itemQuery("航班班次表","航班号");    String item[]=mc.getItem();    int b=mc.getItemNumber();    int j1=0;   for(int i=0;i<b;i++)   {       if(s1.equals(item[i]))       {           //System.out.println("Successful");           JOptionPane.showMessageDialog(this,"添加成功!","消息对话框",JOptionPane.INFORMATION_MESSAGE);           j1=1;           break;       }   }    if(j1==0)        JOptionPane.showMessageDialog(this,"添加失败!","消息对话框",JOptionPane.WARNING_MESSAGE);        //System.err.println("false");    mc.closeConnection();    dispose();}//GEN-LAST:event_jButton1MouseClickedprivate void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked    // TODO add your handling code here:    dispose();}//GEN-LAST:event_jButton2MouseClicked        /**     * @param args the command line arguments     */    public static void main(String args[]) {        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                AddAirJDialog dialog = new AddAirJDialog(new javax.swing.JFrame(), true);                dialog.addWindowListener(new java.awt.event.WindowAdapter() {                    public void windowClosing(java.awt.event.WindowEvent e) {                        System.exit(0);                    }                });                dialog.setVisible(true);            }        });    }        // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel2;    private javax.swing.JLabel jLabel3;    private javax.swing.JLabel jLabel4;    private javax.swing.JLabel jLabel5;    private javax.swing.JLabel jLabel6;    private javax.swing.JLabel jLabel7;    private javax.swing.JTextField jTextField1;    private javax.swing.JTextField jTextField2;    private javax.swing.JTextField jTextField3;    private javax.swing.JTextField jTextField4;    private javax.swing.JTextField jTextField5;    private javax.swing.JTextField jTextField6;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

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