Question

I Have two components C1 and c2, I want C1 to be given just as much horizontal space as it needs and then C2 should grow and take up the remaining horizontal space, however c1 is being given too much space like so:

enter image description here

I want it so that there is no space between the green border edge of the buttons and the red border.

My code to lay out the components is as follows: (c1 being propositionalButtons) (c2 being scrollBox)

this.setLayout(new MigLayout("insets 2, debug, fill"));
this.propositionalButtons = new PropositionalButtons(this.controller);
this.add(propositionalButtons, "top");

this.scrollBox = new JScrollPane();
this.scrollBox.setBorder(BorderFactory.createLineBorder(Color.green));
this.add(scrollBox, "grow");

this.setBackground(Color.BLUE);

Any help would be greatly appreciated! Thanks.

Was it helpful?

Solution

I don't have a compiler handy, but try:

new MigLayout("insets 2, debug, fill", "[][grow]")

This will allow your second column to grow. Currently none of your columns are set to grow, and so the space is distributed among all of them. MiG Layout is not smart enough to cascade the component constraints to the row/column level.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top