SetPreferredSize difference and usage and setSize

1.setPreferredSize required when using layout managers use, the layout manager will get preferredsize space, which can take effect. E.g. borderlayout placed in north in a panel, the panel height may be achieved by: panel.setPreferredSize (new Dimension (0, 100)); This sets a height of the panel 100, with the width of the window changes.

2.setSize, setLocation, setBounds method requires when not in use layout manager, which is setLayout (null) when you can use these three methods to control layout.

Guess you like

Origin www.cnblogs.com/BelieveFish/p/11074777.html