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

📄 jframe2.java

📁 自己在本科毕业时的毕业论文课题,用java语言编写的物业管理系统,很实用!
💻 JAVA
字号:
/* * JFrame_1.java * * Created on 2001年5月1日, 上午9:51 */package zc;import java.sql.*;import java.io.*;/** * * @author  Administrator * @version  */public class JFrame2 extends javax.swing.JFrame {    /** Creates new form JFrame_1 */    public JFrame2() {        initComponents ();        pack ();    }    /** 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 FormEditor.     */    private void initComponents() {//GEN-BEGIN:initComponents        jLabel1 = new javax.swing.JLabel();        jTextField1 = new javax.swing.JTextField();        jLabel2 = new javax.swing.JLabel();        jPasswordField2 = new javax.swing.JPasswordField();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        getContentPane().setLayout(new java.awt.FlowLayout());        addKeyListener(new java.awt.event.KeyAdapter() {            public void keyPressed(java.awt.event.KeyEvent evt) {                formKeyPressed(evt);            }        }        );        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                exitForm(evt);            }        }        );                jLabel1.setText("\u7ba1\u7406\u5458");                getContentPane().add(jLabel1);                        jTextField1.setPreferredSize(new java.awt.Dimension(80, 21));        jTextField1.setColumns(10);        jTextField1.setName("J_tf1");        jTextField1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jTextField1ActionPerformed(evt);            }        }        );                getContentPane().add(jTextField1);                        jLabel2.setText("\u5bc6\u7801");        jLabel2.addKeyListener(new java.awt.event.KeyAdapter() {            public void keyTyped(java.awt.event.KeyEvent evt) {                jLabel2KeyTyped(evt);            }        }        );                getContentPane().add(jLabel2);                        jPasswordField2.setColumns(10);        jPasswordField2.setName("J_tf2");        jPasswordField2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jPasswordField2ActionPerformed(evt);            }        }        );                getContentPane().add(jPasswordField2);                        jButton1.setText("Ok");        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        }        );                getContentPane().add(jButton1);                        jButton2.setText("Cancel");        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        }        );                getContentPane().add(jButton2);            }//GEN-END:initComponents  private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed      confirmPassword();     }//GEN-LAST:event_jButton1ActionPerformed  private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed           zc.JFrame1 jf1=new zc.JFrame1();     jf1.setVisible(true);     setVisible(false);     }//GEN-LAST:event_jButton2ActionPerformed  public void confirmPassword(){       String s1="",s2="",s="htf",password="270098";       s1=jTextField1.getText();       s2=jPasswordField2.getText();       //System.out.println(s1);        //System.out.println(s2);              if(!(s1.equals(s))&&(!(s2.equals(password)))){          //用户名和密码都不正确          javax.swing.JFrame f=new javax.swing.JFrame("MessageDialog");               javax.swing.JOptionPane.showMessageDialog(f,"Wrong Administrator name and Wrong Administrator Password!!","ConfirmMessage",javax.swing.JOptionPane.ERROR_MESSAGE);          int returnValue=0;          if(returnValue==javax.swing.JOptionPane.OK_OPTION)                 f.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);           }       else if(!(s1.equals(s))){                 //用户名不正确;           javax.swing.JFrame f=new javax.swing.JFrame("MessageDialog");               javax.swing.JOptionPane.showMessageDialog(f,"Wrong Administrator name!!","ConfirmMessage",javax.swing.JOptionPane.ERROR_MESSAGE);                      }       //用户名正确,校验密码;              else if(!(s2.equals(password))){          //密码不正确          javax.swing.JFrame f=new javax.swing.JFrame("MessageDialog");               javax.swing.JOptionPane.showMessageDialog(f,"Wrong Administrator Password!!","ConfirmMessage",javax.swing.JOptionPane.ERROR_MESSAGE);          int returnValue=0;          if(returnValue==javax.swing.JOptionPane.OK_OPTION)                 f.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);           }       else   {          zc.face.AdministratorInterface jf4=new zc.face.AdministratorInterface();          jf4.setVisible(true);          setVisible(false);          //密码正确,建立新的界面        }  }           private void jPasswordField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jPasswordField2ActionPerformed            confirmPassword( );        }//GEN-LAST:event_jPasswordField2ActionPerformed  private void jLabel2KeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jLabel2KeyTyped  }//GEN-LAST:event_jLabel2KeyTyped  private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed      // Add your handling code here:  }//GEN-LAST:event_formKeyPressed  private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed            confirmPassword( );       }//GEN-LAST:event_jTextField1ActionPerformed    /** Exit the Application */    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm     }//GEN-LAST:event_exitForm    /**    * @param args the command line arguments    */    public static void main (String args[]) {        JFrame2 jf2=new JFrame2();        jf2.setVisible(true);           }        // Variables declaration - do not modify//GEN-BEGIN:variables    private javax.swing.JLabel jLabel1;    private javax.swing.JTextField jTextField1;    private javax.swing.JLabel jLabel2;    private javax.swing.JPasswordField jPasswordField2;    private javax.swing.JButton jButton1;    private javax.swing.JButton jButton2;    // End of variables declaration//GEN-END:variables     }

⌨️ 快捷键说明

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