If you want to do this for all buttons in an application, you can use UIManager:
UIManager.put("Button.margin", new Insets(10, 10, 10, 10) );
If you want to do this by specifying buttons in the application, you need to make each individual button. However, I do not understand the problem, since somewhere in your code you have to create 25 buttons. Thus, at this point you also set the margin on the button.
source
share