The basic idea of Java GUI program is based on JFrame, which is the object of window on screen, it can be maximized, minimized and closed. Swing is a development kit for developing the Java application user interface. Based on the Abstract Window Toolkit (AWT), you can use any pluggable styling for cross-platform applications. Swing developers can use Swing's rich, flexible features and modular components to create elegant user interfaces with little code.
Frankly speaking, you only need a little code, you can use Java to write out Windows Forms programs, of course, this code is not very small, but compared to the VC6 WIN32 those strange objects, this Java swing program is considered less. And, using JFrame you don't introduce any packages, JDK1.6 has this thing by default.
For example, one of the following jframe Helloworld:
Its code is this:
Import javax.swing.*;p ublic class jfhelloworld{public static void Main (String args[]) {//Create a new JFrame object frame with the title bar No Titlejframe frame=new JFrame ("No Title");//Create a new JLabel component label with the contents of Hello world! JLabel label=new JLabel ("Hello world!"); /Create a new JPanel panel, which is used to place objects JPanel panel=new JPanel ();//Put Labelpanel.add (label) on panel,//Set panel layout as any null layout, This allows the following SetBounds statement to take effect, and the label is in the (125,75) position of the Panel, and the size is 100x20pxpanel.setlayout (null); Label.setbounds (125,75,100,20) ;//Add Panelframe.getcontentpane () to frame. Add (Panel),//Set frame size is 300x200, and visible by default is invisible Frame.setsize (300,200); Frame.setvisible (TRUE);//Make the Close button in the upper right corner take effect, if not, click the Close button in the upper right corner to close the window only, unable to end the process frame.setdefaultcloseoperation (jframe.exit_ on_close);}}
"Java" JFrame Helloworld