Example usage for javax.swing JRadioButtonMenuItem getActionListeners

List of usage examples for javax.swing JRadioButtonMenuItem getActionListeners

Introduction

In this page you can find the example usage for javax.swing JRadioButtonMenuItem getActionListeners.

Prototype

@BeanProperty(bound = false)
public ActionListener[] getActionListeners() 

Source Link

Document

Returns an array of all the ActionListeners added to this AbstractButton with addActionListener().

Usage

From source file:org.yccheok.jstock.gui.JStock.java

private void setLookAndFeel(String lafClassName) {
    boolean uiManagerLookAndFeelSuccess = false;
    String realLafClassName = null;

    try {/*from   w  w w .jav  a2s  . co  m*/
        if (lafClassName == null) {
            String className = Utils.setDefaultLookAndFeel();
            if (className != null) {
                SwingUtilities.updateComponentTreeUI(this);
                realLafClassName = className;
                uiManagerLookAndFeelSuccess = true;
            }
        } else {
            UIManager.setLookAndFeel(lafClassName);
            SwingUtilities.updateComponentTreeUI(this);
            realLafClassName = lafClassName;
            uiManagerLookAndFeelSuccess = true;
        }
    } catch (java.lang.ClassNotFoundException | java.lang.InstantiationException
            | java.lang.IllegalAccessException | javax.swing.UnsupportedLookAndFeelException exp) {
        log.error(null, exp);
    }

    if (uiManagerLookAndFeelSuccess) {
        // Don't use realLafClassName.
        this.jStockOptions.setLooknFeel(lafClassName);

        for (Enumeration<AbstractButton> e = this.buttonGroup1.getElements(); e.hasMoreElements();) {
            AbstractButton button = e.nextElement();
            javax.swing.JRadioButtonMenuItem m = (javax.swing.JRadioButtonMenuItem) button;
            ChangeLookAndFeelAction a = (ChangeLookAndFeelAction) m.getActionListeners()[0];

            if (a.getLafClassName().equals(realLafClassName)) {
                m.setSelected(true);
                break;
            }
        }

        // Sequence are important. The AutoCompleteJComboBox itself should have the highest
        // priority.
        ((AutoCompleteJComboBox) jComboBox1).setStockInfoDatabase(this.stockInfoDatabase);
        this.indicatorPanel.setStockInfoDatabase(this.stockInfoDatabase);
    }
}

From source file:org.yccheok.jstock.gui.MainFrame.java

public void setLookAndFeel(String lafClassName) {
    /* Backward compataible purpose. Old JStockOptions may contain null in this field. */
    if (lafClassName == null) {
        return;/*from w  w w .j  av  a  2s. c om*/
    }
    try {
        UIManager.setLookAndFeel(lafClassName);
        SwingUtilities.updateComponentTreeUI(this);
    } catch (java.lang.ClassNotFoundException exp) {
        log.error(null, exp);
    } catch (java.lang.InstantiationException exp) {
        log.error(null, exp);
    } catch (java.lang.IllegalAccessException exp) {
        log.error(null, exp);
    } catch (javax.swing.UnsupportedLookAndFeelException exp) {
        log.error(null, exp);
    }

    this.jStockOptions.setLookNFeel(lafClassName);

    for (Enumeration<AbstractButton> e = this.buttonGroup1.getElements(); e.hasMoreElements();) {
        AbstractButton button = e.nextElement();
        javax.swing.JRadioButtonMenuItem m = (javax.swing.JRadioButtonMenuItem) button;
        ChangeLookAndFeelAction a = (ChangeLookAndFeelAction) m.getActionListeners()[0];

        if (a.getLafClassName().equals(lafClassName)) {
            m.setSelected(true);
            break;
        }
    }

    // Sequence are important. The AutoCompleteJComboBox itself should have the highest
    // priority.
    ((AutoCompleteJComboBox) jComboBox1).setStockInfoDatabase(this.stockInfoDatabase);
    this.indicatorPanel.setStockInfoDatabase(this.stockInfoDatabase);
}