I\'m new to Java Swing and I have been struggling to start the GridBagLayout from top left corner so that c.gridx=0 c.gridy=0 will put my object on the top left corner.
For those, who use IDE (e.g. NetBeans), I finally found nice trick: if you want to add components to top and use their preferred sizes: add another empty panel with weighty = 1.0. Copied from auto-generated code (NetBeans):
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.weighty = 1.0;
jPanelOptions.add(jPanelFiller, gridBagConstraints);