Example usage for javax.swing JToggleButton setAction

List of usage examples for javax.swing JToggleButton setAction

Introduction

In this page you can find the example usage for javax.swing JToggleButton setAction.

Prototype

@BeanProperty(visualUpdate = true, description = "the Action instance connected with this ActionEvent source")
public void setAction(Action a) 

Source Link

Document

Sets the Action.

Usage

From source file:cl.almejo.vsim.gui.SimWindow.java

private JToggleButton newGrouppedButton(Action action, ButtonGroup group) {
    JToggleButton button = new JToggleButton();
    button.setAction(action);
    button.setText("");
    group.add(button);//from  w  w  w.j  a v a 2  s.c  om
    return button;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java

/** Helper method to create the menu bar. */
private void createMenuBars() {
    rightMenuBar = new JToolBar();
    rightMenuBar.setBorder(null);/*from w ww. j  av a  2 s.  c  om*/
    rightMenuBar.setRollover(true);
    rightMenuBar.setFloatable(false);

    JButton button;
    leftMenuBar = new JToolBar();
    leftMenuBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
    leftMenuBar.setRollover(true);
    leftMenuBar.setFloatable(false);
    BrowserManageAction a;
    int type = model.getBrowserType();
    switch (type) {
    case Browser.PROJECTS_EXPLORER:
    case Browser.SCREENS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_CONTAINER);
        button = new JButton(a);
        button.setName("new container button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.ADMIN_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_ADMIN);
        button = new JButton(a);
        button.setName("new group or user button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
        break;
    case Browser.TAGS_EXPLORER:
        a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_TAG);
        button = new JButton(a);
        button.setName("new tag button");
        button.setBorderPainted(false);
        button.addMouseListener(a);
        rightMenuBar.add(button);
    }
    button = new JButton(controller.getAction(BrowserControl.CUT));
    button.setName("cut button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.COPY));
    button.setName("copy button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.PASTE));
    button.setName("paste button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.DELETE));
    button.setName("delete button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);
    button = new JButton(controller.getAction(BrowserControl.REFRESH));
    button.setName("refresh button");
    button.setBorderPainted(false);
    rightMenuBar.add(button);

    if (type == Browser.ADMIN_EXPLORER) {
        button = new JButton(controller.getAction(BrowserControl.RESET_PASSWORD));
        button.setBorderPainted(false);
        rightMenuBar.add(button);
    } else {
        button = new JButton(controller.getAction(BrowserControl.IMPORT));
        button.setBorderPainted(false);
        //rightMenuBar.add(button);
    }
    rightMenuBar.add(Box.createHorizontalStrut(6));
    rightMenuBar.add(new JSeparator());
    rightMenuBar.add(Box.createHorizontalStrut(6));
    ButtonGroup group = new ButtonGroup();
    JToggleButton b = new JToggleButton();
    group.add(b);
    b.setBorderPainted(true);
    b.setSelected(true);
    b.setAction(controller.getAction(BrowserControl.SORT));

    rightMenuBar.add(b);
    b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE));
    b.setBorderPainted(true);
    group.add(b);
    rightMenuBar.add(b);

    partialButton = new JToggleButton(controller.getAction(BrowserControl.PARTIAL_NAME));
    partialButton.setBorderPainted(true);
    rightMenuBar.add(partialButton);
    rightMenuBar.add(new JSeparator(JSeparator.VERTICAL));
    button = new JButton(controller.getAction(BrowserControl.COLLAPSE));
    button.setBorderPainted(false);
    rightMenuBar.add(button);
}