How do I add the JDesktopPane
to JFrame
using GridBagLayout
and set its height and width. If I add JDesktopPane
that contains JInternalFrame
I don't get anything. But works well in case of GridLayout
but the problem is I can't set my desired size in it as GridLayout
splits equal space among each component added.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You will probably need to set the fill and weight attributes of the GridBagConstraints
...
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.weighty = 1;
gbc.fill = GridBagConstraints.BOTH;
This will cause the component to want to push to the limits of the container and will cause the component to fill it's cell within the grid
This override the components preferred size (for the most part)
Take a look at How to Use GridBagLayout for more details...