use of java.awt.event.WindowEvent in project cayenne by apache.
the class ErrorDebugDialog method init.
protected void init() {
setResizable(false);
Container pane = this.getContentPane();
pane.setLayout(new BorderLayout());
// info area
JEditorPane infoText = new JEditorPane("text/html", infoHTML());
infoText.setBackground(pane.getBackground());
infoText.setEditable(false);
// popup hyperlinks
infoText.addHyperlinkListener(this);
JPanel infoPanel = new JPanel();
infoPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
infoPanel.add(infoText);
pane.add(infoPanel, BorderLayout.NORTH);
// exception area
if (throwable != null) {
exText.setEditable(false);
exText.setLineWrap(true);
exText.setWrapStyleWord(true);
exText.setRows(16);
exText.setColumns(40);
JScrollPane exScroll = new JScrollPane(exText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
exPanel = new JPanel();
exPanel.setLayout(new BorderLayout());
exPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
exPanel.add(exScroll, BorderLayout.CENTER);
// buttons
showHide = new JButton("");
showHide.addActionListener(this);
if (isDetailed()) {
showDetails();
} else {
hideDetails();
}
}
close = new JButton("Close");
close.addActionListener(this);
JButton[] buttons = (showHide != null) ? new JButton[] { showHide, close } : new JButton[] { close };
pane.add(PanelFactory.createButtonPanel(buttons), BorderLayout.SOUTH);
// add a listener to clear static variables, not to produce garbage
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
instance = null;
}
});
// prepare to display
this.pack();
this.centerWindow();
}
use of java.awt.event.WindowEvent in project knime-core by knime.
the class NodeDialog method initDialog.
/*
* Inits the underlying dialog with title and icon.
*/
private JDialog initDialog(final String title) {
JFrame dummy = new JFrame();
if (KNIMEConstants.KNIME16X16 != null) {
dummy.setIconImage(KNIMEConstants.KNIME16X16.getImage());
}
// init underlying dialog
JDialog dialog = new JDialog(dummy);
dialog.setTitle(title);
dialog.setModal(true);
// dialog.setResizable(false);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
dialog.addWindowListener(new WindowAdapter() {
/**
* Invoked when the window close icon X is pressed.
*/
@Override
public void windowClosed(final WindowEvent e) {
onClose(e);
}
/**
* Invoked when the window is opened.
*/
@Override
public void windowOpened(final WindowEvent we) {
onOpen(we);
}
});
return dialog;
}
use of java.awt.event.WindowEvent in project eclipse.platform.swt by eclipse.
the class Bug306490_SwingDisposeError method createSwing.
static void createSwing() {
JFrame frame = new JFrame("Swing, close me (before or after closing the other window)");
frame.setBounds(0, 0, 600, 100);
frame.addWindowListener(new // same bug with using setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE) instead
WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();
System.out.println("Swing: disposed");
}
});
// remark 1: comment out the following line (do not add textArea) and all works fine
frame.getContentPane().add(new JTextArea());
frame.setVisible(true);
}
use of java.awt.event.WindowEvent in project vcell by virtualcell.
the class ExpressionCanvas 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();
ExpressionCanvas aExpressionCanvas;
aExpressionCanvas = new ExpressionCanvas();
frame.setContentPane(aExpressionCanvas);
frame.setSize(aExpressionCanvas.getSize());
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.setVisible(true);
Insets insets = frame.getInsets();
frame.setSize(frame.getWidth() + insets.left + insets.right, frame.getHeight() + insets.top + insets.bottom);
frame.setVisible(true);
} catch (Throwable exception) {
System.err.println("Exception occurred in main() of javax.swing.JPanel");
exception.printStackTrace(System.out);
}
}
use of java.awt.event.WindowEvent in project vcell by virtualcell.
the class BeanUtils method addCloseWindowKeyboardAction.
public static void addCloseWindowKeyboardAction(JComponent jComponent) {
@SuppressWarnings("serial") Action winCloseAction = new AbstractAction() {
@Override
public synchronized void actionPerformed(ActionEvent e) {
Window window = null;
if (e.getSource() != null) {
if (e.getSource() instanceof Window) {
window = (Window) e.getSource();
} else {
window = (Window) BeanUtils.findTypeParentOfComponent((Component) e.getSource(), Window.class);
}
}
if (window != null) {
window.dispatchEvent(new WindowEvent(window, java.awt.event.WindowEvent.WINDOW_CLOSING));
}
}
};
final String winCloseInputMapAction = "winCloseAction";
InputMap inputMap = jComponent.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
if (inputMap.get(CLOSE_WINDOW_KEY_STROKE) == null) {
inputMap.put(CLOSE_WINDOW_KEY_STROKE, winCloseInputMapAction);
jComponent.getActionMap().put(winCloseInputMapAction, winCloseAction);
}
}
Aggregations