This is driving me crazy. When I set an appropriate size for my window in design-mode it just ignores this size and uses something else when I compile and run. Even tough I set the minimumSize and preferredSize it just ignores this… Why? How can I set my own size?
Share
Even if you’ve set the size with
minimumSizeandpreferredSize, you might have forgotten to callWindow.pack()in which Swing will resize the components (and all of it’s subcomponents) according to the sizes set.You call it in your window (or whatever is building your window) after all the preferred sizes are set.
Alternatively you can use the
Component.setSize()method but it comes with some caveats.