List of utility methods to do JButton Settings
JRadioButton | addRadioButton(JPanel buttonPanel, ButtonGroup group, String buttonName, boolean selected, ActionListener listener) ------------------------------------------------------------- addRadioButton JRadioButton button = new JRadioButton(buttonName, selected); button.addActionListener(listener); (button.getModel()).setActionCommand(buttonName); group.add(button); buttonPanel.add(button); return button; |
T | addToButtonGroup(ButtonGroup bg, T button) add To Button Group bg.add(button);
return button;
|
void | applyDefaultProperties(final Button 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"); |
boolean | askYesNoQuestion(String dlgTitle, String question, Component parent, Object[] buttonTittle) Shows a yes and no dialog with a specified question Object[] options = { "Yes", "No" }; if (buttonTittle != null) { if (buttonTittle.length == 2) { options[0] = buttonTittle[0]; options[1] = buttonTittle[1]; int n = JOptionPane.showOptionDialog(parent, question, dlgTitle, JOptionPane.YES_NO_OPTION, ... |
ButtonGroup | buttonGroup(AbstractButton b1, AbstractButton b2) buttonGroup. return buttonGroup(new AbstractButton[] { b1, b2 }); |
ButtonGroup | buttonGroup(JToggleButton b1, JToggleButton b2) Create a button group and add the two buttons to it. ButtonGroup bg = new ButtonGroup(); bg.add(b1); bg.add(b2); return bg; |
boolean | clickButton(final Window window, final String buttonText) click Button final JButton button = findButton(window, buttonText); if (button == null) return false; if (!button.isEnabled()) { button.setEnabled(true); logToConsole("Button was disabled, has been enabled: " + buttonText); logToConsole("Click button: " + buttonText); ... |
void | configureOKAndCancelButtons(JPanel panel, Action ok, Action cancel) configure OK And Cancel Buttons final ActionMap actionMap = panel.getActionMap(); final InputMap inputMap = panel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); if (cancel != null) { actionMap.put(cancel.getValue(Action.ACTION_COMMAND_KEY), cancel); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancel.getValue(Action.ACTION_COMMAND_KEY)); if (ok != null) { actionMap.put(ok.getValue(Action.ACTION_COMMAND_KEY), ok); ... |
void | configureTextAndMnemonic(AbstractButton button, String text) configure Text And Mnemonic int length = text.length(); int index = text.indexOf('&'); if (index == -1) { button.setText(text); } else { StringBuilder newText = new StringBuilder(length); int mnemonic = -1; int mnemonicIndex = -1; ... |
int | confirm(Component comp, String title, String message, int buttons, int type) Displays a confirm dialog box and returns the button pushed by the user. return JOptionPane.showConfirmDialog(comp, message, title, buttons, type);
|