java.awt no cross-platform javax.swing with cross-platform all classes start with J
JButton is the form in javax.swing corresponding to java.awt in the form of a button
Elements of the interface (found in the API documentation):
Top-level container (form) javax.swing.JFrame
Text, picture label Javax.swing.JLabel
Text input Box Javax.swing.JTextField
Password input Box Javax.swing.JPasswordField
check box (tick) Javax.swing.JCheckBox
Button Javax.swing.JButton
Picture Javax.swing.ImageIcon
Text javax.swing.String
Size Java.awt.Dimension
Flow layout Java.awt.FlowLayout (an element then an element is arranged downward, if one line is not enough to move to the next line, so by adjusting the length to be the same element alignment)
Steps to do the interface: Create an interface class and define a method for the login interface
To create a form:
Javax.swing.JFrame frame=new javax.swing.JFrame ();
Frame.settitle ("QQ login");
Frame.setsize (400,400);
Frame.setlocationrelativeto (NULL); ......... Center position (position)
Frame.setdefaultcloseoperation (Jframe.exit_on_close); ........... Click x to close all [several close several]
Dispose_on_close ..... Click X to close the corresponding one [other not off]
Do_nothing_on_close ..... Dot x doesn't have any effect
Set the layout of the form to flow layout: Java.awt.FlowLayout flow=new java.awt.FlowLayout ();
Frame.setlayout (flow);
Insert Picture label: Javax.swing.ImageIcon icon=new Javax.swing.ImageIcon (GetClass (). GetResource ("title.jpg"));
Javax.swing.JLabel iconlabel=new Javax.swing.JLabel (icon);
Iconlabel.setpreferredsize (New Java.awt.Dimension (400,200));
Frame.add (IconLabel);
Insert User name tag: Javax.swing.JLabel usernamelabel=new javax.swing.JLabel ("User name");
Usernamelabel.setpreferredsize (New Java.awt.Dimension (80,25));
Frame.add (Usernamelabel);
Insert User name Input box: Javax.swing.JTextField usernametext=new Javax.swing.JTextField ();
Usernametext.setpreferredsize (New Java.awt.Dimension (280,25));
Frame.add (Usernametext);
Or:
Javax.swing.JTextField usernametext=new Javax.swing.JTextField ();
Java.awt.Dimension untextsize=new java.awt.Dimension (280,25);
Usernametext.setpreferredsize (untextsize);
Frame.add (Usernametext);
Java Interface Development