Swing desktop program (article 2nd)

Source: Internet
Author: User
Controls in Swing can be divided into three types: top-level containers, non-top-level containers, and common controls. 1) The top-layer container is a control that can be directly displayed on the system desktop, that is, the outermost layer container of the GUI application. Other controls must be directly or indirectly displayed using top-level containers. Top-level containers generally include the JFrame window class, JWindow class, And JDialog class.

Controls in Swing can be divided into three types: top-level containers, non-top-level containers, and common controls. 1) The top-layer container is a control that can be directly displayed on the system desktop, that is, the outermost layer container of the GUI application. Other controls must be directly or indirectly displayed using top-level containers. Top-level containers generally include the JFrame window class, JWindow class, And JDialog class.

Controls in Swing can be divided into three types: top-level containers, non-top-level containers, and common controls.

1) The top-layer container is a control that can be directly displayed on the system desktop, that is, the outermost layer container of the GUI application. Other controls must be directly or indirectly displayed using top-level containers.

Top-level containers generally include the JFrame window class, JWindow class, And JDialog class.

2) Non-top-level containers are used in top-level containers. for top-level containers, non-top-level containers are general controls.

You can also add controls to non-top-level containers. For these controls, a non-top-level container is a container.

Non-top-layer containers include the JPanel class.

3) common controls account for the majority of controls. Using these controls can implement specific functions, but common controls do not act as containers.

Package com. whut. sw;

Import javax. swing .*;
Public class Swing7 extends JFrame {
JPanel jp = new JPanel ();
JButton jb = new JButton ();
// Define the constructor
Public Swing7 (){
This. setTitle ("create panel ");
Jb. setText ("this is a button ");

Jp. add (jb );
This. add (jp );
This. setBounds (300,250,300,200 );
This. setVisible (true );
}
Public static void main (String [] args ){
Swing7 s = new Swing7 ();

}

}
---------------------------------------------------------------------------------

The result is as follows:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.