use of java.awt.event.WindowAdapter in project vcell by virtualcell.
the class MathModelEditorAnnotationPanel method main.
/**
* main entrypoint - starts the part when it is run as an application
* @param args java.lang.String[]
*/
public static void main(String[] args) {
try {
JFrame frame = new JFrame();
MathModelEditorAnnotationPanel aEditSpeciesPanel = new MathModelEditorAnnotationPanel();
frame.add(aEditSpeciesPanel);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of cbit.gui.JInternalFrameEnhanced");
exception.printStackTrace(System.out);
}
}
use of java.awt.event.WindowAdapter in project jgnash by ccavanaugh.
the class ConsoleDialog method show.
public static void show() {
if (dialog == null) {
// only one visible window
init();
ResourceBundle rb = ResourceUtils.getBundle();
JButton copyButton = new JButton(rb.getString("Button.CopyToClip"));
copyButton.addActionListener(e -> {
if (console != null) {
console.selectAll();
console.copy();
}
});
JButton gcButton = new JButton(rb.getString("Button.ForceGC"));
gcButton.addActionListener(e -> System.gc());
JButton heapButton = new JButton(rb.getString("Button.CreateHeapDump"));
heapButton.addActionListener(e -> {
if (console != null) {
dumpHeap();
}
});
dialog = new JDialog(UIApplication.getFrame(), Dialog.ModalityType.MODELESS);
dialog.setTitle(rb.getString("Title.Console"));
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
/* force the shut down to the end of the event thread.
* Lets other listeners do their job */
EventQueue.invokeLater(() -> {
synchronized (consoleLock) {
ConsoleDialog.close();
}
});
}
});
synchronized (consoleLock) {
console = new JTextArea();
console.setEditable(false);
// set a mono spaced font to preserve spacing
console.setFont(new Font("Monospaced", Font.PLAIN, console.getFont().getSize()));
}
JPanel panel = new JPanel();
panel.setBorder(Borders.DIALOG);
panel.setLayout(new BorderLayout());
panel.add(new MemoryMonitor(), BorderLayout.NORTH);
panel.add(new JScrollPane(console), BorderLayout.CENTER);
JPanel buttonPanel = StaticUIMethods.buildRightAlignedBar(heapButton, gcButton, copyButton);
buttonPanel.setBorder(new EmptyBorder(10, 0, 10, 0));
panel.add(buttonPanel, BorderLayout.SOUTH);
dialog.getContentPane().add(panel, BorderLayout.CENTER);
dialog.pack();
// Minimum size
dialog.setMinimumSize(dialog.getSize());
dialog.setFocusableWindowState(false);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
DialogUtils.addBoundsListener(dialog);
dialog.setVisible(true);
}
}
use of java.awt.event.WindowAdapter in project jgnash by ccavanaugh.
the class DynamicJasperReportFrame method init.
private void init() {
statusField = new JTextField();
statusField.setEditable(false);
statusField.setFont(statusField.getFont().deriveFont(statusField.getFont().getSize2D() - 1f));
statusField.setHorizontalAlignment(SwingConstants.CENTER);
JXStatusBar statusBar = new JXStatusBar();
JXStatusBar.Constraint c1 = new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL);
statusBar.add(statusField, c1);
statusBar.setResizeHandleEnabled(true);
setIconImage(IconUtils.getImage("/jgnash/resource/gnome-money.png"));
waitPanel = new WaitMessagePanel();
setGlassPane(waitPanel);
mainPanel = new JPanel();
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
unregisterLogHandler();
viewer.clear();
getContentPane().removeAll();
}
});
mainPanel.setLayout(new BorderLayout());
getContentPane().add(mainPanel, BorderLayout.CENTER);
getContentPane().add(statusBar, BorderLayout.SOUTH);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
setMinimumSize(new Dimension(500, 440));
pack();
DialogUtils.addBoundsListener(this);
}
use of java.awt.event.WindowAdapter in project languagetool by languagetool-org.
the class FontChooser method initComponents.
private void initComponents() {
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "Hide");
getRootPane().getActionMap().put("Hide", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
selectedFont = null;
setVisible(false);
}
});
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
selectedFont = null;
setVisible(false);
}
});
setTitle(messages.getString("FontChooser.title"));
fontStylesArray = new String[] { messages.getString("FontChooser.style.plain"), messages.getString("FontChooser.style.bold"), messages.getString("FontChooser.style.italic"), messages.getString("FontChooser.style.bold_italic") };
String[] fontNamesArray = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
getContentPane().setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(4, 4, 4, 4);
JPanel fontPanel = new JPanel(new GridBagLayout());
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
JLabel fontNameLabel = new JLabel(messages.getString("FontChooser.label.name"));
fontPanel.add(fontNameLabel, c);
c.gridx = 1;
c.gridy = 0;
JLabel fontStyleLabel = new JLabel(messages.getString("FontChooser.label.style"));
fontPanel.add(fontStyleLabel, c);
c.gridx = 2;
c.gridy = 0;
JLabel fontSizeLabel = new JLabel(messages.getString("FontChooser.label.size"));
fontPanel.add(fontSizeLabel, c);
c.gridx = 0;
c.gridy = 1;
c.weightx = 1.0;
c.fill = GridBagConstraints.HORIZONTAL;
fontNameTextField = new JTextField();
fontNameTextField.setEnabled(false);
fontNameTextField.getDocument().addDocumentListener(this);
fontPanel.add(fontNameTextField, c);
c.weightx = 0.0;
c.gridx = 1;
c.gridy = 1;
fontStyleTextField = new JTextField();
fontStyleTextField.setEnabled(false);
fontStyleTextField.getDocument().addDocumentListener(this);
fontPanel.add(fontStyleTextField, c);
c.gridx = 2;
c.gridy = 1;
fontSizeTextField = new JTextField();
fontSizeTextField.setColumns(4);
fontSizeTextField.getDocument().addDocumentListener(this);
fontPanel.add(fontSizeTextField, c);
c.gridx = 0;
c.gridy = 2;
c.weightx = 1.0;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
fontNameList = new JList<>(fontNamesArray);
fontNameList.addListSelectionListener(this);
fontNameList.setVisibleRowCount(5);
fontNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane fontNameListPane = new JScrollPane(fontNameList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
fontPanel.add(fontNameListPane, c);
c.gridx = 1;
c.gridy = 2;
c.weightx = 0.5;
fontStyleList = new JList<>(fontStylesArray);
fontStyleList.addListSelectionListener(this);
fontStyleList.setVisibleRowCount(5);
fontStyleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane fontStyleListPane = new JScrollPane(fontStyleList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
fontPanel.add(fontStyleListPane, c);
c.gridx = 2;
c.gridy = 2;
fontSizeList = new JList<>(fontSizesArray);
fontSizeList.addListSelectionListener(this);
fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
fontSizeList.setVisibleRowCount(5);
JScrollPane fontSizeListPane = new JScrollPane(fontSizeList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
fontPanel.add(fontSizeListPane, c);
c.insets = new Insets(8, 8, 4, 8);
c.gridx = 0;
c.gridy = 0;
c.weightx = 0.0;
c.weighty = 0.4;
getContentPane().add(fontPanel, c);
c.insets = new Insets(4, 8, 4, 8);
c.gridx = 0;
c.gridy = 1;
c.weightx = 1.0;
c.weighty = 0.6;
previewArea = new JTextArea(messages.getString("FontChooser.pangram"));
previewArea.setLineWrap(true);
previewArea.setRows(4);
JScrollPane pane = new JScrollPane(previewArea);
TitledBorder border = BorderFactory.createTitledBorder(messages.getString("FontChooser.preview"));
pane.setBorder(border);
getContentPane().add(pane, c);
JPanel buttonPanel = new JPanel(new GridBagLayout());
c.insets = new Insets(4, 4, 4, 4);
c.gridx = 0;
c.gridy = 0;
c.weightx = 1.0;
c.weighty = 0.0;
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.NONE;
JButton resetButton = new JButton(Tools.getLabel(messages.getString("FontChooser.reset")));
resetButton.setMnemonic(Tools.getMnemonic(messages.getString("FontChooser.reset")));
resetButton.setActionCommand(ACTION_COMMAND_RESET);
resetButton.addActionListener(this);
buttonPanel.add(resetButton, c);
c.gridx = 1;
c.gridy = 0;
c.weightx = 0.0;
c.weighty = 0.0;
c.anchor = GridBagConstraints.LINE_END;
c.fill = GridBagConstraints.NONE;
JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
cancelButton.addActionListener(this);
buttonPanel.add(cancelButton, c);
c.gridx = 2;
c.gridy = 0;
JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
okButton.setActionCommand(ACTION_COMMAND_OK);
okButton.addActionListener(this);
buttonPanel.add(okButton, c);
c.insets = new Insets(4, 8, 8, 8);
c.gridx = 0;
c.gridy = 2;
c.anchor = GridBagConstraints.LINE_START;
c.fill = GridBagConstraints.HORIZONTAL;
getContentPane().add(buttonPanel, c);
this.defaultFont = previewArea.getFont();
setDefaultFont();
getRootPane().setDefaultButton(cancelButton);
this.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
pack();
}
use of java.awt.event.WindowAdapter in project gephi by gephi.
the class DataLaboratoryHelper method executeAttributeColumnsManipulator.
/**
* Prepares the dialog UI of a AttributeColumnsManipulator if it has one and executes the manipulator in a separate
* Thread when the dialog is accepted or directly if there is no UI.
* @param m AttributeColumnsManipulator
* @param graphModel Graph model of the table
* @param table Table of the column
* @param column Column to manipulate
*/
public void executeAttributeColumnsManipulator(final AttributeColumnsManipulator m, final GraphModel graphModel, final Table table, final Column column) {
if (m.canManipulateColumn(table, column)) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final AttributeColumnsManipulatorUI ui = m.getUI(table, column);
//Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
if (ui != null) {
final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
DialogControls dialogControls = new DialogControlsImpl(okButton);
ui.setup(m, graphModel, table, column, dialogControls);
JPanel settingsPanel = ui.getSettingsPanel();
DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(okButton)) {
ui.unSetup();
executeAttributeColumnsManipulatorInOtherThread(m, table, column);
} else {
ui.unSetup();
}
}
});
dd.setOptions(new Object[] { okButton, DialogDescriptor.CANCEL_OPTION });
//All options close
dd.setClosingOptions(null);
Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
ui.unSetup();
}
});
dialog.setVisible(true);
} else {
executeAttributeColumnsManipulatorInOtherThread(m, table, column);
}
}
});
}
}
Aggregations