Java JButton Settings setBtnValue(ButtonGroup group, String value)

Here you can find the source of setBtnValue(ButtonGroup group, String value)

Description

set Btn Value

License

Open Source License

Declaration

public static void setBtnValue(ButtonGroup group, String value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Enumeration;
import javax.swing.AbstractButton;
import javax.swing.ButtonGroup;

public class Main {

    public static void setBtnValue(ButtonGroup group, String value) {
        for (Enumeration<AbstractButton> e = group.getElements(); e
                .hasMoreElements();) {/*from  w ww  .java 2  s. co  m*/
            AbstractButton btn = e.nextElement();
            if (btn.getActionCommand().equals(value)) {
                group.setSelected(btn.getModel(), true);
                break;
            }
        }
    }
}

Related

  1. selectFile(final int openMode, final String title, final String buttonText, final String lastDirectoryUsed, final Component parent, final String suffix, final String description)
  2. selectWithoutNotifyingListeners(AbstractButton ab, boolean selected)
  3. setAction(AbstractButton btn, ActionListener listener, String actionCommand)
  4. setAllEnabled(final ButtonGroup buttonGroup, final boolean enabled)
  5. setAutoMnemonic(AbstractButton button)
  6. setButton(AbstractButton button, Icon icon, ActionListener buttonListener)
  7. setButtonContentMargin(AbstractButton button, Insets margin)
  8. setButtonInsetsRecursive(Insets insets, Container container)
  9. setButtonSelected(ButtonGroup buttonGroup, int selected)