Example usage for javax.swing AbstractButton getAction

List of usage examples for javax.swing AbstractButton getAction

Introduction

In this page you can find the example usage for javax.swing AbstractButton getAction.

Prototype

public Action getAction() 

Source Link

Document

Returns the currently set Action for this ActionEvent source, or null if no Action is set.

Usage

From source file:Main.java

public static void main(String[] args) {
    AbstractButton jb = new JButton("Press Me");
    jb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            System.out.println(((JComponent) arg0.getSource()).getFont());
        }/*from w  w  w .j  ava2s  .  c o m*/
    });
    System.out.println(jb.getAction());
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(jb);
    f.pack();
    f.setVisible(true);
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Updates UI components when a new color model is selected.
 * //ww w .j av  a 2s . c o  m
 * @param key The index of the color model.
 */
void setColorModel(int key) {
    controlPane.setColorModel();
    AbstractButton b;
    Action a;
    Enumeration<AbstractButton> e;
    for (e = colorModelGroup.getElements(); e.hasMoreElements();) {
        b = e.nextElement();
        a = b.getAction();
        if (a instanceof ColorModelAction) {
            b.removeActionListener(a);
            b.setSelected(((ColorModelAction) a).getIndex() == key);
            b.setAction(a);
        }
    }
}