This may not answer your immediate question…but…
GridLayout layout = new GridLayout(1, 2); this.setLayout(layout); // You're original code... // Why are you using `BorderLayout.CENTER` on a `GridLayout` this.add(new PaintSurface(), BorderLayout.CENTER);
You set the layout as a
GridLayout, but you are using
BorderLayout constraints to apply one of the components??
Also, make sure that there are not calls to
Test#pack else where in your code, as this will override the values of
UPDATED (from changes to question)
Remember, the default layout manager for
BorderLayout, so even though you’re calling
buttonPanel.setSize, it’s likely that it’s begin overridden by the layout manager anyway.
If you can’t find a single one, consider using compound components with different layout managers to bring the layout closer to what you want to achieve.