use of javax.swing.AbstractAction in project EnrichmentMapApp by BaderLab.
the class PostAnalysisPanelMediator method showDialog.
@SuppressWarnings("serial")
public void showDialog(Component parent, CyNetworkView netView) {
final EnrichmentMap map = emManager.getEnrichmentMap(netView.getModel().getSUID());
invokeOnEDT(() -> {
final PostAnalysisInputPanel panel = panelFactory.create(map);
final JDialog dialog = new JDialog(swingApplication.getJFrame(), "Add Signature Gene Sets", ModalityType.APPLICATION_MODAL);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
JButton helpButton = SwingUtil.createOnlineHelpButton(EnrichmentMapBuildProperties.USER_MANUAL_URL, "Online Manual...", serviceRegistrar);
JButton resetButton = new JButton("Reset");
resetButton.addActionListener(e -> panel.reset());
JButton closeButton = new JButton(new AbstractAction("Close") {
@Override
public void actionPerformed(ActionEvent e) {
dialog.dispose();
}
});
JButton runButton = new JButton(new AbstractAction("Add") {
@Override
public void actionPerformed(ActionEvent e) {
if (panel.isReady()) {
Optional<PostAnalysisParameters> params = buildPostAnalysisParameters(panel, map, dialog);
if (params.isPresent()) {
addGeneSets(netView, params.get());
dialog.dispose();
} else {
JOptionPane.showMessageDialog(panel, "Could not run post analysis.", "EnrichmentMap: Error", JOptionPane.WARNING_MESSAGE);
}
}
}
});
JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(runButton, closeButton, helpButton, resetButton);
dialog.getContentPane().add(panel, BorderLayout.CENTER);
dialog.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), runButton.getAction(), closeButton.getAction());
dialog.getRootPane().setDefaultButton(runButton);
dialog.pack();
dialog.setLocationRelativeTo(swingApplication.getJFrame());
dialog.setVisible(true);
});
}
use of javax.swing.AbstractAction in project EnrichmentMapApp by BaderLab.
the class CardDialog method createButtonPanel.
@SuppressWarnings("serial")
private JPanel createButtonPanel() {
finishButton = new JButton(new AbstractAction(params.getFinishButtonText()) {
public void actionPerformed(ActionEvent e) {
currentPage.finish();
}
});
JButton cancelButton = new JButton(new AbstractAction("Cancel") {
public void actionPerformed(ActionEvent e) {
dialog.setVisible(false);
}
});
AbstractButton[] additional = params.getAdditionalButtons();
if (additional != null) {
for (AbstractButton button : additional) {
button.addActionListener(e -> {
currentPage.extraButtonClicked(e.getActionCommand());
});
}
}
JPanel buttonPanel = LookAndFeelUtil.createOkCancelPanel(finishButton, cancelButton, additional);
LookAndFeelUtil.setDefaultOkCancelKeyStrokes(dialog.getRootPane(), finishButton.getAction(), cancelButton.getAction());
dialog.getRootPane().setDefaultButton(finishButton);
return buttonPanel;
}
use of javax.swing.AbstractAction in project zaproxy by zaproxy.
the class StandardFieldsDialog method initialize.
private void initialize(Dimension dim, String[] tabLabels) {
this.setLayout(new GridBagLayout());
this.setSize(dim);
if (tabLabels == null) {
this.initializeSinglePane(dim);
} else {
this.initializeTabbed(dim, tabLabels);
}
// 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 = 1L;
@Override
public void actionPerformed(ActionEvent e) {
if (hasCancelSaveButtons()) {
cancelPressed();
return;
}
savePressed();
}
};
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 LinearGradientPrintingTest method createUI.
public static void createUI() {
f = new JFrame("LinearGradient Printing Test");
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
final LinearGradientPrintingTest gpt = new LinearGradientPrintingTest();
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