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: