java Swing components disposed in the container changes form with adaptive

Swing components, such as the form to make the container change adaptively trans fat or reduced play, the container layout may be in the Gridlayout

code show as below:

JPanel panel_2 = new JPanel();
tabbedPane.addTab("tab2", null, panel_2, null);
panel_2.setLayout(new GridLayout(0, 2, 10, 0));
        
JPanel panel_3 = new JPanel();
panel_3.setBackground(Color.PINK);
panel_2.add(panel_3);
        
JPanel panel_4 = new JPanel();
panel_4.setBackground(Color.ORANGE);
panel_2.add(panel_4);

Results are as follows:

Narrow circumstances:

 

 Full screen situation:

 

Guess you like

Origin www.cnblogs.com/liyuanhong/p/12121370.html