I'm trying to place two JPanels onto a JFrame using GridBagLayout. The first JPanel uses gridLayout to create 35 columns and 27 rows of JButtons, and should have a width of 3/4 of the JFrame. This panel needs to fill the vertical space available to it. The second JPanel also uses gridLayout and should fill the last 1/4 of the main JFrame.
Unfortunately, my first JPanel (sPan) isn't even fitting properly on the screen, and is forcing the whole second JPanel (cPan) off of the screen. How can I constrain these values to take up only their allowed proportion on the screen without them moving each other around?
If I use a blank JPanel with a background colour with my code, everything works out perfectly fine:
However, when I use my JPanel consisting of JButtons, the proportions get completely messed up:
I speculate that when I instantiate my sPan object, it's sizing each button to accommodate the size of the whole JFrame. Then when I instantiate the cPan object and try to place it next to the sPan object, the buttons aren't resizing themselves to accommodate the additional panel in the main JFrame. Does anybody know how I can fix this?
I have to use GridBagLayout for this assignment, so using normal gridLayout isn't an option. Any tips regarding what's happening would be appreciated.