Skip to content
Advertisement

Swing BorderLayout: Make no space between buttons, no center gap

I have this code:

JavaScript

When I run it, it shows:

enter image description here

However when I resize this window:

enter image description here

How do I make it so that buttons take up 100% of the windows, like this:

enter image description here

I tried to do this:

JavaScript

but it worked even worse:

enter image description here

enter image description here

I also tried:

JavaScript

but it gave the original result.

Advertisement

Answer

This layout can be easily achieved by using a GridLayout (green) for the buttons, in the CENTER of a BorderLayout (red) for the main GUI.

enter image description here

Advertisement