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

📄 securitypanel.java

📁 电话号码薄应用程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
         } // end anonymous inner class      ); // end call to addActionListener      // set up enterJButton      enterJButton = new JButton();      enterJButton.setBounds( 180, 214, 50, 50 );      enterJButton.setText( "#" );      contentPane.add( enterJButton );      enterJButton.addActionListener(         new ActionListener() // anonymous inner class         {            // event handler called when enterJButton is pressed            public void actionPerformed( ActionEvent event )            {               enterJButtonActionPerformed( event );            }         } // end anonymous inner class      ); // end call to addActionListener      // set up zeroJButton      zeroJButton = new JButton();      zeroJButton.setBounds( 130, 214, 50, 50 );      zeroJButton.setText( "0" );      contentPane.add( zeroJButton );      zeroJButton.addActionListener(         new ActionListener() // anonymous inner class         {            // event handler called when zeroJButton is pressed            public void actionPerformed( ActionEvent event )            {               zeroJButtonActionPerformed( event );            }         } // end anonymous inner class      ); // end call to addActionListener      // set up accessLogJLabel      accessLogJLabel = new JLabel();      accessLogJLabel.setBounds( 16, 285, 100, 16 );      accessLogJLabel.setText( "Access log:" );      contentPane.add( accessLogJLabel );      // set up accessLogJTextArea      accessLogJTextArea = new JTextArea();      // set up accessLogJScrollPane      accessLogJScrollPane = new JScrollPane( accessLogJTextArea );      accessLogJScrollPane.setBounds( 16, 309, 270, 95 );      contentPane.add( accessLogJScrollPane );      // set properties of application's window      setTitle( "Security Panel" ); // set title bar string      setSize( 310, 450 );          // set window's size      setVisible( true );           // display window      // ensure synthesizer is cleaned up      // when user closes application      addWindowListener(         new WindowAdapter()  // anonymous inner class         {            public void windowClosing( WindowEvent event )            {               frameWindowClosing( event );            }         } // end anonymous inner class      ); // end addWindowListener   } // end method createUserInterface   // append 0 to the security code   private void zeroJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "0" );   } // end method zeroJButtonActionPerformed   // append 1 to the security code   private void oneJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "1" );   } // end method oneJButtonActionPerformed   // append 2 to the security code   private void twoJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "2" );   } // end method twoJButtonActionPerformed   // append 3 to the security code   private void threeJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "3" );   } // end method threeJButtonActionPerformed   // append 4 to the security code   private void fourJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "4" );   } // end method fourJButtonActionPerformed   // append 5 to the security code   private void fiveJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "5" );   } // end method fiveJButtonActionPerformed   // append 6 to the security code   private void sixJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "6" );   } // end method sixJButtonActionPerformed   // append 7 to the security code   private void sevenJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "7" );   } // end method sevenJButtonActionPerformed   // append 8 to the security code   private void eightJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "8" );   } // end method eightJButtonActionPerformed   // clears the securityCodeJPasswordField   private void clearJButtonActionPerformed( ActionEvent event )   {     securityCodeJPasswordField.setText( "" );   } // end method clearJButtonActionPerformed   // append 9 to the security code   private void nineJButtonActionPerformed( ActionEvent event )   {      securityCodeJPasswordField.setText( String.valueOf(          securityCodeJPasswordField.getPassword() ) + "9" );   } // end method nineJButtonActionPerformed      // gets access code and determines level of clearance   private void enterJButtonActionPerformed( ActionEvent event )   {      String message; // displays access status of users      // stores access code entered      int accessCode = Integer.parseInt( String.valueOf(             securityCodeJPasswordField.getPassword() ) );      securityCodeJPasswordField.setText( "" );       switch ( accessCode ) // check access code input      {         // access code is 7, 8 or 9         case 7:         case 8:         case 9:            message = "Restricted Access";            break; // done processing case         // access code equal to 1645         case 1645:            message = "Technician";            break; // done processing case         // access code equal to 8345         case 8345:            message = "Custodian";            break; // done processing case         // access code equal to 9998 or between 1006 and 1008         case 9998:         case 1006:         case 1007:         case 1008:            message = "Scientist";            break; // done processing case         // if no other case is true         default:            message = "Access Denied";      } // end switch statement      // display time and message in JTextArea      DateFormat formatter = DateFormat.getDateTimeInstance();      accessLogJTextArea.append( formatter.format( new Date() ) +          "   " + message + "\n" );   } // end method enterJButtonActionPerformed      // clean up synthesizer   private void frameWindowClosing( WindowEvent event )   {         }  // end method frameWindowClosing   // main method   public static void main( String[] args )   {      SecurityPanel application = new SecurityPanel();   } // end method main} // end class SecurityPanel/************************************************************************** * (C) Copyright 1992-2004 by Deitel & Associates, Inc. and               * * Pearson Education, Inc. All Rights Reserved.                           * *                                                                        * * DISCLAIMER: The authors and publisher of this book have used their     * * best efforts in preparing the book. These efforts include the          * * development, research, and testing of the theories and programs        * * to determine their effectiveness. The authors and publisher make       * * no warranty of any kind, expressed or implied, with regard to these    * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or       * * consequential damages in connection with, or arising out of, the       * * furnishing, performance, or use of these programs.                     * **************************************************************************/

⌨️ 快捷键说明

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