I can\'t make the pack() method work. I tried several things. My code looks like this at the moment:
Class 1:
public static void main( String[] args
pack(). The pack method tells the layout managers and components to size themselves optimally, and if you instead use null layouts, then the gui risks shrinking to a minimal size, since there is no layout to hold it together.setSize(...) and pack(). The layouts mostly respect the preferred sizes of components, not their sizes.Instead:
pack(), then setLocationByPlatform(true) (I think), then setVisible(true).For better help, please check out the Swing Layout Manager Tutorials.
Here are a couple examples to other questions on this site that use various layout managers: