Importjavax.swing.*;Importjava.awt.*;//Import the necessary packages Public classDengluextendsjframe{JTextField JTextField;//Defining a text box componentJPasswordField JPasswordField;//Define a Password box componentJLabel Jlabel1,jlabel2; JPanel jp1,jp2,jp3; JButton jb1,jb2; //Create button PublicDenglu () {JTextField=NewJTextField (12); JPasswordField=NewJPasswordField (13); JLabel1=NewJLabel ("User name"); JLabel2=NewJLabel ("Password"); JB1=NewJButton ("Confirm"); JB2=NewJButton ("Cancel"); JP1=NewJPanel (); JP2=NewJPanel (); JP3=NewJPanel (); //Set Layout This. setlayout (NewGridLayout (3,1)); Jp1.add (JLABEL1); Jp1.add (JTextField);//First Panel add user name and text boxJp2.add (JLABEL2); Jp2.add (JPasswordField);//Second Panel add password and password input boxJp3.add (JB1); Jp3.add (JB2); //Third Panel add confirmation and cancellation//jp3.setlayout (New FlowLayout ()); //because JPanel default layout is FlowLayout, you can unregister this code. This. Add (JP1); This. Add (JP2); This. Add (JP3);//add three panels to the landing box//Set Display This. setSize (300, 200); //This.pack (); This. Setdefaultcloseoperation (Jframe.exit_on_close); This. setvisible (true); This. Settitle ("Login"); } Public Static voidMain (string[] args) {NewDenglu (); }}
What you want.