I’m writing MineSweeper and using JButtons on a GridLayout. The numbers of rows and columns are entered by the user, so setting fixed size may cause several problems.
How can I remove the space between the buttons without setting the fixed size of the panel?

This seems to be more of a issue with
JButtonthen withGridLayoutHere, I replaced
JButtonwithJPanel(and some border magic)The other thing I tried was passing a negative h/vgap to the
GridLayoutI’d however not recommend this, as it may have unforeseen effects on other platforms.
I personally, would be tempted to use a custom
JLabel(with it’s own mouse listener attached) to take the place of the buttons. You could even fire and action event when it’s clicked…