You could try using the GridBagLayout
. Read the section from the Swing tutorial on How to Use GridBagLayout for more information. I would guess you would need to play with the weightx
property.
Or you could use the Relative Layout which was specifically designed to do this.
Edit:
Did you do any debugging? What happens when you add:
System.out.println(menuLeft.getPreferredSize());
System.out.println(contentRight.getPreferredSize());
You have two problems:
- What is the value of 1/3? You need to fix your size calculation.
- What is the size of your rootPanel? A component doesn't have a size until the component is displayed on the visible GUI. You set the preferred size of the component.