SOURCE program:
1 ImportJava.awt.EventQueue;2 ImportJavax.swing.JFrame;3 ImportJava.awt.Color;4 ImportJavax.swing.JPanel;5 Importjava.awt.BorderLayout;6 ImportJavax.swing.JLabel;7 ImportJavax.swing.JTextField;8 ImportJavax.swing.JPasswordField;9 ImportJavax.swing.JButton;Ten Importjavax.swing.event.*; One ImportJava.awt.Font; A Public classLoginwindow { - - PrivateJFrame frame; the PrivateJPasswordField Passwordfield; - - /** - * Launch the application. + */ - Public Static voidMain (string[] args) { +Eventqueue.invokelater (NewRunnable () { A Public voidrun () { at Try { -Loginwindow window =NewLoginwindow (); -Window.frame.setVisible (true); -}Catch(Exception e) { - e.printstacktrace (); - } in } - }); to } + - /** the * Create the application. * */ $ PublicLoginwindow () {Panax Notoginseng Initialize (); - } the + /** A * Initialize The contents of the frame. the */ + Private voidInitialize () { -frame =NewJFrame (); $ Frame.setbackground (color.blue); $Frame.setbounds (100, 100, 445, 319); - frame.setdefaultcloseoperation (jframe.exit_on_close); - theJPanel Panel =NewJPanel (); - Frame.getcontentpane (). Add (Panel, borderlayout.center);WuyiPanel.setvisible (true); thePanel.setlayout (NULL); - WuJLabel label =NewJLabel ("\U767B\U5F55\U540D\UFF1A"); -Label.setfont (NewFont ("Microsoft Jas Black", Font.plain, 18)); AboutLabel.setbounds (85, 44, 76, 32); $ panel.add (label); - -JLabel Label_1 =NewJLabel ("\U5BC6\U7801\UFF1A"); -Label_1.setfont (NewFont ("Microsoft Jas Black", Font.plain, 18)); ALabel_1.setbounds (85, 86, 76, 32); + Panel.add (label_1); the -JLabel label_2 =NewJLabel ("\U9A8C\U8BC1\U7801\UFF1A"); $Label_2.setfont (NewFont ("Microsoft Jas Black", Font.plain, 18)); theLabel_2.setbounds (84, 128, 76, 30); the Panel.add (label_2); the theJTextField TextArea =NewJTextField (); -Textarea.setborder (Javax.swing.BorderFactory.createLineBorder (NewJava.awt.Color (255,0,0))); inTextarea.setbounds (181, 44, 166, 34); the Panel.add (TextArea); the AboutPasswordfield =NewJPasswordField (); thePasswordfield.setborder (Javax.swing.BorderFactory.createLineBorder (NewJava.awt.Color (255,0,0))); thePasswordfield.setbounds (181, 86, 166, 34); the Panel.add (Passwordfield); + -JButton Btnnewbutton =NewJButton ("\u767b\u5f55"); theBtnnewbutton.setenabled (false);BayiBtnnewbutton.setbackground (NewColor (51, 153, 0)); the Btnnewbutton.setforeground (color.black); theBtnnewbutton.setbounds (124, 186, 181, 29); - Panel.add (Btnnewbutton); - theJButton btnnewbutton_1 =NewJButton ("\u5feb\u901f\u6ce8\u518c"); theBtnnewbutton_1.setbackground (NewColor (255, 204, 255)); theBtnnewbutton_1.setbounds (124, 225, 181, 29); the Panel.add (btnnewbutton_1); - the theString result = ""; the for(inti = 0;i < 6;i++)94 { the intc = (int) (Math.random () * 26 + 97); theresult = result + (Char) C; the }98JLabel Lblvalid =NewJLabel (result); AboutLblvalid.setbounds (277, 134, 70, 22); - Panel.add (lblvalid);101 102JTextField textarea_1 =NewJTextField ();103Textarea_1.getdocument (). Adddocumentlistener (NewDocumentlistener () {104 Public voidinsertupdate (documentevent e) { the if(Textarea_1.gettext (). Equals (Lblvalid.gettext ())) {106Btnnewbutton.setenabled (true);107 }108 Else{109Btnnewbutton.setenabled (false); the }111 } the Public voidremoveupdate (documentevent e) {113 if(Textarea_1.gettext (). Equals (Lblvalid.gettext ())) { theBtnnewbutton.setenabled (true); the } the Else{117Btnnewbutton.setenabled (false);118 }119 } - Public voidchangedupdate (documentevent e) {121 122 }123 });124 theTextarea_1.setborder (Javax.swing.BorderFactory.createLineBorder (NewJava.awt.Color (255,0,0)));126Textarea_1.setbounds (180, 128, 76, 32);127 Panel.add (textarea_1); - }129}