The list of methods to do JButton Default are organized into topic(s).
void
applyDefaultProperties(final JButton comp) Sets default background and foreground color as well as a default font for the specified component.
if (comp == null) {
return;
applyProperties(comp, "Button.background",
"Button.foreground",
"Button.font");
void
setDefaultButton(JButton jButton) set Default Button
if (jButton == null) {
throw new IllegalArgumentException();
jButton.getRootPane().setDefaultButton(jButton);
void
setupWindowContentPane(final Window aWindow, final Component aCenterComponent, final Component aButtonPane, final JButton defaultButton) Sets up the given window content pane by setting its border to provide a good default spacer, and setting the content pane to the given components.
final JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBorder(BorderFactory.createEmptyBorder(DIALOG_PADDING, DIALOG_PADDING,
DIALOG_PADDING, DIALOG_PADDING));
contentPane.add(aCenterComponent, BorderLayout.CENTER);
contentPane.add(aButtonPane, BorderLayout.PAGE_END);
if (aWindow instanceof JDialog) {
((JDialog) aWindow).setContentPane(contentPane);
((JDialog) aWindow).getRootPane().setDefaultButton(defaultButton);
...