use of javax.swing.AbstractAction in project binnavi by google.
the class CGraphHotkeys method registerSearchKeys.
/**
* Registers the hot keys used for searching through graphs.
*
* @param view View searched by the hotkey actions.
* @param searchField Search field used for searching through the graph.
* @param inputMap Input map where the hotkeys are registered.
* @param actionMap Action map where the hotkey actions are stored.
*/
private static void registerSearchKeys(final Graph2DView view, final CGraphSearchField searchField, final InputMap inputMap, final ActionMap actionMap) {
inputMap.put(HotKeys.GRAPH_SEARCHFIELD_FOCUS_KEY.getKeyStroke(), "FOCUS_SEARCHFIELD");
view.getInputMap().put(HotKeys.GRAPH_SEARCH_NEXT_KEY.getKeyStroke(), "NEXT");
inputMap.put(HotKeys.GRAPH_SEARCH_NEXT_ZOOM_KEY.getKeyStroke(), "NEXT_ZOOM");
inputMap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_KEY.getKeyStroke(), "PREVIOUS");
inputMap.put(HotKeys.GRAPH_SEARCH_PREVIOUS_ZOOM_KEY.getKeyStroke(), "PREVIOUS_ZOOM");
view.getActionMap().put("NEXT", new AbstractAction() {
private static final long serialVersionUID = -7289167985570632361L;
@Override
public void actionPerformed(final ActionEvent event) {
searchField.centerNextSearchHit(false, false);
}
});
actionMap.put("NEXT_ZOOM", new AbstractAction() {
private static final long serialVersionUID = -74113347341296669L;
@Override
public void actionPerformed(final ActionEvent event) {
searchField.centerNextSearchHit(false, true);
}
});
actionMap.put("PREVIOUS", new AbstractAction() {
private static final long serialVersionUID = 5698412623106859554L;
@Override
public void actionPerformed(final ActionEvent event) {
searchField.centerNextSearchHit(true, false);
}
});
actionMap.put("PREVIOUS_ZOOM", new AbstractAction() {
/**
* Used for serialization.
*/
private static final long serialVersionUID = -5246885767421937156L;
@Override
public void actionPerformed(final ActionEvent event) {
searchField.centerNextSearchHit(true, true);
}
});
actionMap.put("FOCUS_SEARCHFIELD", new AbstractAction() {
/**
* Used for serialization.
*/
private static final long serialVersionUID = 7918948798657638098L;
@Override
public void actionPerformed(final ActionEvent event) {
searchField.requestFocusInWindow();
}
});
}
use of javax.swing.AbstractAction in project zaproxy by zaproxy.
the class ManageAddOnsDialog method initialize.
/**
* This method initializes this
*
*/
private void initialize() {
this.setTitle(Constant.messages.getString("cfu.manage.title"));
//this.setContentPane(getJTabbed());
this.setContentPane(getTopPanel());
this.pack();
if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
this.setSize(700, 500);
}
state = State.IDLE;
// Handle escape key to close the dialog
KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
AbstractAction escapeAction = new AbstractAction() {
private static final long serialVersionUID = 3516424501887406165L;
@Override
public void actionPerformed(ActionEvent e) {
dispatchEvent(new WindowEvent(ManageAddOnsDialog.this, WindowEvent.WINDOW_CLOSING));
}
};
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
getRootPane().getActionMap().put("ESCAPE", escapeAction);
}
use of javax.swing.AbstractAction in project zaproxy by zaproxy.
the class AbstractDialog method initialize.
/**
* This method initializes this
*/
private void initialize() {
this.setVisible(false);
this.setIconImages(DisplayUtils.getZapIconImages());
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
this.setSize(300, 200);
}
this.setTitle(Constant.PROGRAM_NAME);
// Handle escape key to close the dialog
KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
AbstractAction escapeAction = new AbstractAction() {
private static final long serialVersionUID = 3516424501887406165L;
@Override
public void actionPerformed(ActionEvent e) {
dispatchEvent(new WindowEvent(AbstractDialog.this, WindowEvent.WINDOW_CLOSING));
}
};
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
getRootPane().getActionMap().put("ESCAPE", escapeAction);
}
use of javax.swing.AbstractAction in project jdk8u_jdk by JetBrains.
the class RadialGradientPrintingTest method createUI.
public static void createUI() {
f = new JFrame("RadialGradient Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final RadialGradientPrintingTest gpt = new RadialGradientPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
use of javax.swing.AbstractAction in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method printTexture.
private static void printTexture() {
f = new JFrame("Texture Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final TexturePaintPrintingTest gpt = new TexturePaintPrintingTest();
Container c = f.getContentPane();
c.add(BorderLayout.CENTER, gpt);
final JButton print = new JButton("Print");
print.addActionListener(new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(gpt);
final boolean doPrint = job.printDialog();
if (doPrint) {
try {
job.print();
} catch (PrinterException ex) {
throw new RuntimeException(ex);
}
}
}
});
c.add(print, BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
}
Aggregations