I'm trying to acchieve the following layout with the GridBagLayout, but seem to be having problems getting the weights correct. Any tips?
One of the things you need to decide when designing a layout is what happens on stretching or shrinking the window, and you haven't specified that.
I am not a proponent of GridBagLayout, finding that I have never had to do anything that I couldn't do more easily with other layouts.
If, for instance, you wanted all the panels in your figure to maintain their sizes relative to each other, I'd make one panel for the left and right groups of three, and put those in the 'left' and 'right' of a BorderLayout. Then I'd make another panel with BorderLayout and set the left and right individual panels you have into the left and right of those panels, and put the horizontal panels into the top and bottom of those panels.
Frame (BorderLayout by default)
left leftPanelOf3
top horizontalPanel1
left verticalPanel1
right verticalPanel2
right rightPanelOf3
left verticalPanel3
right verticalPanel4
bottom horizontalPanel2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.