Search code examples
javaswinguser-interfacelayoutgridbaglayout

Positioning using GridBagLayout


As you can see in my output below, the label is displayed on top of my "next piece" grid. I know why this is happening (because my grid bag constraints are at the same location) but if I increase the y component of these constraints, my "next piece" grid is moved the the y coordinate after the larger grid. I would like to have the "next piece" grid where it is with the label right over top of it.

Any suggestions?

enter image description here


Solution

  • Either

    1. Use a compound layout (placing the two components on the left in there own container and then adding that to the main container) or
    2. Take a look at the gridheight property of GridBagConstraints (for the other two components right of the problem area)