Java Utililty Methods JButton Settings

List of utility methods to do JButton Settings

Description

The list of methods to do JButton Settings are organized into topic(s).

Method

JButtongetButton(Container c, String text)
get Button
if (c.isShowing()) {
    if (c.getComponents().length == 0) {
        if (c instanceof JButton) {
            JButton b = (JButton) c;
            String btxt = b.getText();
            if (btxt != null && btxt.equalsIgnoreCase(text)) {
                return b;
    } else {
        for (Component sub : c.getComponents()) {
            if (sub instanceof Container) {
                JButton b = getButton((Container) sub, text);
                if (b != null) {
                    return b;
return null;
JButtongetButton(Container container, String text)
get Button
JButton btn = null;
List<Container> children = new ArrayList<>(25);
for (Component child : container.getComponents()) {
    if (child instanceof JButton) {
        JButton button = (JButton) child;
        if (text.equals(button.getText())) {
            btn = button;
            break;
...
JButtongetButton(String displayText, ActionListener actionListener)
get Button
return getButton(displayText, actionListener, null);
JButtongetButtonAsLink(String text)
get Button As Link
JButton button = new JButton();
button.setText(text);
button.setHorizontalAlignment(SwingConstants.RIGHT);
button.setBorderPainted(false);
button.setOpaque(true);
button.setForeground(Color.BLUE);
return button;
ColorgetButtonBorderColor(Color color)
get Button Border Color
if ((DARK_GREEN.equals(color)) || (DARK_MAGENTA.equals(color))) {
    return new ColorUIResource(Color.WHITE);
return color;
ColorgetButtonColor()
Get the color for the custom editor button if specified by the theme or look and feel, or null if the defaults should simply be used
return UIManager.getColor("netbeans.ps.buttonColor"); 
JPanelgetButtonPane()
get Button Pane
final JPanel buttonPane = new JPanel();
buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
buttonPane.add(Box.createHorizontalGlue());
buttonPane.setAlignmentX(Component.LEFT_ALIGNMENT);
return buttonPane;
ColorgetButtonSelectColor()
get Button Select Color
return UIManager.getColor("Button.select");
intgetButtonSelectedInt(ButtonGroup buttonGroup)
get Button Selected Int
try {
    return Integer.parseInt(getButtonSelectedString(buttonGroup));
} catch (NumberFormatException e) {
    return -1;
StringgetButtonSelectedString(ButtonGroup buttonGroup)
get Button Selected String
return buttonGroup.getSelection().getActionCommand();