Reputation: 39695
I have created a simple JFrame
with two labels, two fields and two buttons. ContentPane
with BoxLayout
has a JPanel. JPanel with MigLayout
have all the 6 components. Components are placed relatively and growable, but I am forced to give bounds to JFrame
, which I would like to avoid. If I avoid setBounds()
. Frame appears very small and it shows only window buttons
. If I mention some size to JFrame
, it can accomodate components well in Windows
not in Mac
(Buttons
at bottom are truncated a little). Specifying greater frame size spares look and feel
in Windows
.
Is it possible to make a JFrame growing automatically with respect to its child components? or to make it accomodate everything dynamically without setting bounds?
Upvotes: 2
Views: 1584
Reputation: 168825
make it accomodate everything dynamically without setting bounds?
Call pack()
.
Causes this Window to be sized to fit the preferred size and layouts of its subcomponents. ..
Upvotes: 4