What\'s the easiest way to make a JPanel
that takes up a fixed percentage of its parent container, by width?
Its width should update when that of its pa
You could use the Relative Layout. This layout was designed for this purpose since none of the layouts from the JDK support this directly (and easily).
As a simple example you could have 3 panels at 25%, 25% and 50% of the width:
RelativeLayout rl = new RelativeLayout(RelativeLayout.X_AXIS);
rl.setFill( true );
JPanel panel = new JPanel( rl );
panel.add(red, new Float(25);
panel.add(green, new Float(25));
panel.add(blue, new Float(50));