// typical code to use GridBagLayout. Container contentPane = jframe.getContentPane(); contentPane.setLayout ( new GridBagLayout() ); // x y w h wtx wty anchor fill T L B R padx pady contentPane.add( myPanel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets( 10, 10, 10, 5 ), 0, 0 ) ); contentPane.add( myPanel2, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets( 10, 5, 10, 10 ), 0, 0 ) );