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;
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations