use of javax.swing.AbstractAction in project jdk8u_jdk by JetBrains.
the class Test8013370 method run.
@Override
public void run() {
if (this.frame == null) {
JMenuBar menu = new JMenuBar() {
@Override
protected boolean processKeyBinding(KeyStroke stroke, KeyEvent event, int condition, boolean pressed) {
if (stroke == null) {
Test8013370.this.error = true;
return false;
}
return super.processKeyBinding(stroke, event, condition, pressed);
}
};
menu.add(new JMenuItem("Menu"));
InputMap map = menu.getInputMap(WHEN_IN_FOCUSED_WINDOW);
// from a array to a hashtable when more than 8 values are added.
for (int i = 0; i < 9; i++) {
String name = " Action #" + i;
map.put(KeyStroke.getKeyStroke(KeyEvent.VK_A + i, CTRL_DOWN_MASK), name);
menu.getActionMap().put(name, new AbstractAction(name) {
@Override
public void actionPerformed(ActionEvent event) {
showMessageDialog(null, getValue(NAME));
}
});
}
this.frame = new JFrame("8013370");
this.frame.setJMenuBar(menu);
this.frame.setVisible(true);
} else {
this.frame.dispose();
}
}
use of javax.swing.AbstractAction in project scylla by bptlab.
the class ScyllaGUI method initKeyBindings.
/**
* Initializes key bindings and key event redirection to the current selected panel
*/
public void initKeyBindings() {
contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK), ACTIONKEY_SAVE);
contentPane.getActionMap().put(ACTIONKEY_SAVE, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
((JComponent) contentPane.getSelectedComponent()).getActionMap().get(ACTIONKEY_SAVE).actionPerformed(e);
}
});
contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK), ACTIONKEY_SAVEAS);
contentPane.getActionMap().put(ACTIONKEY_SAVEAS, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
((JComponent) contentPane.getSelectedComponent()).getActionMap().get(ACTIONKEY_SAVEAS).actionPerformed(e);
}
});
contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK), ACTIONKEY_OPEN);
contentPane.getActionMap().put(ACTIONKEY_OPEN, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
((JComponent) contentPane.getSelectedComponent()).getActionMap().get(ACTIONKEY_OPEN).actionPerformed(e);
}
});
contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK), ACTIONKEY_NEW);
contentPane.getActionMap().put(ACTIONKEY_NEW, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
((JComponent) contentPane.getSelectedComponent()).getActionMap().get(ACTIONKEY_NEW).actionPerformed(e);
}
});
}
use of javax.swing.AbstractAction in project knime-core by knime.
the class ParallelCoordinatesPlotter method getHideAction.
/**
* @return the menu item for hide unhilited.
*/
public Action getHideAction() {
Action hide = new AbstractAction(AbstractPlotter.HIDE_UNHILITED) {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
m_hide = true;
if (getDrawingPane() instanceof ParallelCoordinateDrawingPane) {
getParCoordDrawinPane().setFadeUnhilited(false);
getParCoordDrawinPane().setHideUnhilited(true);
}
updatePaintModel();
}
};
return hide;
}
use of javax.swing.AbstractAction in project knime-core by knime.
the class ParallelCoordinatesPlotter method getShowAllAction.
// ---------- menu -------------
/**
* @return the menu item for show all.
*/
public Action getShowAllAction() {
Action show = new AbstractAction(AbstractPlotter.SHOW_ALL) {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
m_hide = false;
if (getDrawingPane() instanceof ParallelCoordinateDrawingPane) {
getParCoordDrawinPane().setFadeUnhilited(false);
getParCoordDrawinPane().setHideUnhilited(false);
}
updatePaintModel();
}
};
return show;
}
use of javax.swing.AbstractAction in project knime-core by knime.
the class ScatterPlotter method getHideAction.
/**
* The <code>ScatterPlotter</code> adds the posssibility to show, fade or
* hide unhilited dots and this is the hide unhilited action. The hide flag
* is administered in the <code>ScatterPlotter</code>, since hidden
* points are not passed to the
* {@link org.knime.base.node.viz.plotter.scatter
* .ScatterPlotterDrawingPane},
* the fade flag is administered in the
* {@link org.knime.base.node.viz.plotter.scatter
* .ScatterPlotterDrawingPane},
* since the dots are painted but with a different (faded) color.
*
* @return the menu item for hide unhilited.
*/
public Action getHideAction() {
Action hide = new AbstractAction(AbstractPlotter.HIDE_UNHILITED) {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
m_hide = true;
if (getDrawingPane() instanceof ScatterPlotterDrawingPane) {
getScatterPlotterDrawingPane().setFadeUnhilited(false);
}
updatePaintModel();
}
};
return hide;
}
Aggregations