List of utility methods to do JButton Default
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 | ensureDefaultButtonWidth(JButton button) Ensures a button has a specific minimum width, similar to what Windows does. ensureButtonWidth(button, DEFAULT_BUTTON_SIZE); |
void | setDefaultButton(final JRootPane rp, final JButton b) set Default Button rp.setDefaultButton(b); |
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); ... |