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

📄 myjframe.java

📁 简单的实现学生信息管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel8)                    .addComponent(jRadioButton1)                    .addComponent(jRadioButton2))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel6)                    .addComponent(jRadioButton3)                    .addComponent(jRadioButton4))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel5)                    .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel7)                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addGap(20, 20, 20)                .addComponent(jLabel9)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jButton2)                    .addComponent(jButton1))                .addContainerGap(36, Short.MAX_VALUE))        );        jLabel10.setText("请上传您的照片");        jButton3.setText("浏览");        jButton3.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton3ActionPerformed(evt);            }        });        jTextField1.setColumns(10);        jButton4.setText("上传");        jButton4.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton4ActionPerformed(evt);            }        });        jButton5.setText("取消");        jMenu1.setText("File");        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK));        jMenuItem1.setText("查询");        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jMenuItem1ActionPerformed(evt);            }        });        jMenu1.add(jMenuItem1);        jMenuBar1.add(jMenu1);        jMenu2.setText("Edit");        jMenu2.addMenuListener(new javax.swing.event.MenuListener() {            public void menuCanceled(javax.swing.event.MenuEvent evt) {            }            public void menuDeselected(javax.swing.event.MenuEvent evt) {            }            public void menuSelected(javax.swing.event.MenuEvent evt) {                jMenu2MenuSelected(evt);            }        });        jMenu2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jMenu2ActionPerformed(evt);            }        });        jMenuBar1.add(jMenu2);        setJMenuBar(jMenuBar1);        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());        getContentPane().setLayout(layout);        layout.setHorizontalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(layout.createSequentialGroup()                .addContainerGap()                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addGroup(layout.createSequentialGroup()                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)                                .addGroup(layout.createSequentialGroup()                                    .addComponent(jTextField1)                                    .addGap(18, 18, 18)                                    .addComponent(jButton3))                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 234, javax.swing.GroupLayout.PREFERRED_SIZE))                            .addGroup(layout.createSequentialGroup()                                .addComponent(jButton4)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(jButton5)))                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))                .addGap(43, 43, 43))        );        layout.setVerticalGroup(            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(layout.createSequentialGroup()                        .addContainerGap()                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE)                        .addGap(39, 39, 39)                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                            .addComponent(jButton3)                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                        .addGap(17, 17, 17)                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                            .addComponent(jButton4)                            .addComponent(jButton5)))                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                .addContainerGap())        );        pack();    }// </editor-fold>//GEN-END:initComponents    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed        // TODO add your handling code here:    }//GEN-LAST:event_jRadioButton1ActionPerformed    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed        // TODO add your handling code here:    }//GEN-LAST:event_jRadioButton2ActionPerformed    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed        java.awt.EventQueue.invokeLater(new Runnable() {            public void run() {                new Ask().setVisible(true);            }        });    }//GEN-LAST:event_jMenuItem1ActionPerformed    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed        try {            String str, sql, url, user, password, jb1, jb2;            Connection conn;            Statement stmt;            ResultSet rst;            str = "sun.jdbc.odbc.JdbcOdbcDriver";            Class.forName(str);            conn = DriverManager.getConnection("jdbc:odbc:student", "Administer", "");            stmt = (Statement) conn.createStatement();            if (jRadioButton1.isSelected()) {                jb1 = "男";            } else {                jb1 = "女";            }            if (jRadioButton3.isSelected()) {                jb2 = "是";            } else {                jb2 = "否";            }            try {                stmt.executeUpdate("insert into 学生信息 values ('" + jTextField2.getText() + "' , '" + jTextField3.getText() + "', " +                        "  '" + jb1 + "','" + jb2 + "', '" + jComboBox1.getSelectedItem() + "','" + jTextArea1.getText() + "','" + jSpinner1.getValue() + "')");            } catch (SQLException sQLException) {                            }            stmt.close();            conn.close();        } catch (Exception e) {            e.printStackTrace();        } finally {            if(jTextField2.getText().equals("")){                JOptionPane.showMessageDialog(this,"请输入完整信息");            }            else {                JOptionPane.showMessageDialog(this, "成功保存!");            }        }    }//GEN-LAST:event_jButton1ActionPerformed    private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed        System.exit(0);    }//GEN-LAST:event_jMenu2ActionPerformed    private void jMenu2MenuSelected(javax.swing.event.MenuEvent evt) {//GEN-FIRST:event_jMenu2MenuSelected        int i = 0;        i = JOptionPane.showConfirmDialog(MyJFrame.this, "您真的要退出吗?", "", 1);        if (i == JOptionPane.YES_OPTION) {            System.exit(0);        }    }//GEN-LAST:event_jMenu2MenuSelected    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed        JFileChooser jf = new JFileChooser("C://");        jf.setDialogTitle("Chose...");        File filepath = null;        File selectedFile = null;        FileNameExtensionFilter fef = new FileNameExtensionFilter("JPG Files", "jpg");        jf.setFileFilter(fef);        int result = jf.showOpenDialog(MyJFrame.this);        jf.setVisible(true);        if (result == JFileChooser.APPROVE_OPTION) {            selectedFile = jf.getSelectedFile();            ImageIcon icon = new ImageIcon(selectedFile.getPath());            jTextField1.setText(selectedFile.getPath());        }    }//GEN-LAST:event_jButton3ActionPerformed    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed        ImageIcon icon = new ImageIcon(jTextField1.getText());        jLabel10.setIcon(icon);    }//GEN-LAST:event_jButton4ActionPerformed    /**     * @param args the command line arguments     */    public static void main(String args[]) {    }    // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.ButtonGroup buttonGroup1;    private javax.swing.ButtonGroup buttonGroup2;    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    private javax.swing.JButton jButton3;    private javax.swing.JButton jButton4;    private javax.swing.JButton jButton5;    private javax.swing.JComboBox jComboBox1;    private javax.swing.JDialog jDialog1;    private javax.swing.JFrame jFrame1;    private javax.swing.JLabel jLabel1;    private javax.swing.JLabel jLabel10;    private javax.swing.JLabel jLabel12;    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.JLabel jLabel8;    private javax.swing.JLabel jLabel9;    private javax.swing.JMenu jMenu1;    private javax.swing.JMenu jMenu2;    private javax.swing.JMenuBar jMenuBar1;    private javax.swing.JMenuItem jMenuItem1;    private javax.swing.JPanel jPanel1;    private javax.swing.JPanel jPanel2;    private javax.swing.JRadioButton jRadioButton1;    private javax.swing.JRadioButton jRadioButton2;    private javax.swing.JRadioButton jRadioButton3;    private javax.swing.JRadioButton jRadioButton4;    private javax.swing.JScrollPane jScrollPane1;    private javax.swing.JSpinner jSpinner1;    private javax.swing.JTextArea jTextArea1;    private javax.swing.JTextField jTextField1;    private javax.swing.JTextField jTextField2;    private javax.swing.JTextField jTextField3;    // End of variables declaration//GEN-END:variables}

⌨️ 快捷键说明

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