Search in sources :

Example 96 with Action

use of javax.swing.Action in project com.revolsys.open by revolsys.

the class BaseStylePanel method getTextAlignActions.

public static List<Action> getTextAlignActions(final String... alignmentTypes) {
    final List<Action> actions = new ArrayList<>();
    for (final String alignmentType : alignmentTypes) {
        final I18nAction action = new I18nAction(alignmentType, null, CaseConverter.toCapitalizedWords(alignmentType), Icons.getIcon("text_align_" + alignmentType));
        actions.add(action);
    }
    return actions;
}
Also used : I18nAction(com.revolsys.swing.action.I18nAction) Action(javax.swing.Action) ArrayList(java.util.ArrayList) I18nAction(com.revolsys.swing.action.I18nAction)

Example 97 with Action

use of javax.swing.Action in project ffx by mjschnie.

the class MainMenu method addCBMenuItem.

private JCheckBoxMenuItem addCBMenuItem(JMenu menu, String icon, String actionCommand, int mnemonic, int accelerator, final ActionListener actionListener) {
    final JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem();
    Action a = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            /**
             * If the ActionEvent is from a ToolBar button, pass it through
             * the JCheckBoxMenuItem.
             */
            if (e.getSource() != menuItem) {
                menuItem.doClick();
                return;
            }
            actionListener.actionPerformed(e);
        }
    };
    configureAction(a, icon, actionCommand, mnemonic, accelerator);
    menuItem.setAction(a);
    menu.add(menuItem);
    return menuItem;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) AbstractAction(javax.swing.AbstractAction) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem)

Example 98 with Action

use of javax.swing.Action in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method addSubmenuItems.

/**
 * Creates a sub-menu item for each choice of a given preference
 * (<code>pref</code>) and adds it to a given parent menu (<code>parent</code>).
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void addSubmenuItems(JMenu parent, ChoicePref pref) {
    Object selected = pref.get();
    for (Object item : pref.validChoices()) {
        Action action = pref.getAction(item);
        menuItem(parent, pref.renderValueLong(item).toString(), action, item == selected ? iconYes : iconNo);
    }
}
Also used : Action(javax.swing.Action)

Example 99 with Action

use of javax.swing.Action in project org.alloytools.alloy by AlloyTools.

the class SimpleGUI method addToMenu.

/**
 * Creates menu items from boolean preferences (<code>prefs</code>) and adds
 * them to a given parent menu (<code>parent</code>).
 */
private void addToMenu(JMenu parent, BooleanPref... prefs) {
    for (BooleanPref pref : prefs) {
        Action action = pref.getTitleAction();
        Object name = action.getValue(Action.NAME);
        menuItem(parent, name + ": " + (pref.get() ? "Yes" : "No"), action);
    }
}
Also used : Action(javax.swing.Action) BooleanPref(edu.mit.csail.sdg.alloy4.A4Preferences.BooleanPref)

Example 100 with Action

use of javax.swing.Action in project CodenameOne by codenameone.

the class PerformanceMonitor method createJTable.

private static JTable createJTable() {
    final JTable t = new JTable(createTableModel()) {

        MultilineTableCell wordWrapRenderer = new MultilineTableCell();

        public TableCellRenderer getCellRenderer(int row, int column) {
            if (column < 3) {
                return wordWrapRenderer;
            } else {
                return super.getCellRenderer(row, column);
            }
        }
    };
    Action view = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            JTable table = (JTable) e.getSource();
            int modelRow = Integer.valueOf(e.getActionCommand());
            String s = (String) ((DefaultTableModel) table.getModel()).getValueAt(modelRow, 3);
            JOptionPane.showMessageDialog(t, s, "Stack", JOptionPane.INFORMATION_MESSAGE);
        }
    };
    ButtonColumn buttonColumn = new ButtonColumn(t, view, 3);
    buttonColumn.setMnemonic(KeyEvent.VK_D);
    return t;
}
Also used : Action(javax.swing.Action) AbstractAction(javax.swing.AbstractAction) ActionEvent(java.awt.event.ActionEvent) JTable(javax.swing.JTable) AttributedString(java.text.AttributedString) AbstractAction(javax.swing.AbstractAction)

Aggregations

Action (javax.swing.Action)249 AbstractAction (javax.swing.AbstractAction)168 ActionEvent (java.awt.event.ActionEvent)128 InputMap (javax.swing.InputMap)48 KeyStroke (javax.swing.KeyStroke)44 JPanel (javax.swing.JPanel)36 JMenu (javax.swing.JMenu)32 JPopupMenu (javax.swing.JPopupMenu)32 JButton (javax.swing.JButton)31 ArrayList (java.util.ArrayList)29 JRootPane (javax.swing.JRootPane)28 JMenuItem (javax.swing.JMenuItem)27 ActionMap (javax.swing.ActionMap)24 JScrollPane (javax.swing.JScrollPane)20 SwingAction (games.strategy.ui.SwingAction)19 BorderLayout (java.awt.BorderLayout)18 JDialog (javax.swing.JDialog)18 MouseEvent (java.awt.event.MouseEvent)16 Dimension (java.awt.Dimension)15 BoxLayout (javax.swing.BoxLayout)15