use of java.awt.event.WindowAdapter in project jmonkeyengine by jMonkeyEngine.
the class TestSafeCanvas method main.
public static void main(String[] args) throws InterruptedException {
AppSettings settings = new AppSettings(true);
settings.setWidth(640);
settings.setHeight(480);
final TestSafeCanvas app = new TestSafeCanvas();
app.setPauseOnLostFocus(false);
app.setSettings(settings);
app.createCanvas();
app.startCanvas(true);
JmeCanvasContext context = (JmeCanvasContext) app.getContext();
Canvas canvas = context.getCanvas();
canvas.setSize(settings.getWidth(), settings.getHeight());
Thread.sleep(3000);
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
app.stop();
}
});
frame.getContentPane().add(canvas);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Thread.sleep(3000);
frame.getContentPane().remove(canvas);
Thread.sleep(3000);
frame.getContentPane().add(canvas);
}
use of java.awt.event.WindowAdapter in project jmonkeyengine by jMonkeyEngine.
the class TestAwtPanels method createWindowForPanel.
private static void createWindowForPanel(AwtPanel panel, int location) {
JFrame frame = new JFrame("Render Display " + location);
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
if (++panelsClosed == 2) {
app.stop();
}
}
});
frame.pack();
frame.setLocation(location, Toolkit.getDefaultToolkit().getScreenSize().height - 400);
frame.setVisible(true);
}
use of java.awt.event.WindowAdapter in project lwjgl by LWJGL.
the class DemoBox method initialize.
/**
* @return
*/
public boolean initialize() {
setTitle("LWJGL - Demo Box");
setSize(640, 480);
setLayout(new GridBagLayout());
// Setup selection panel
// =================================
selectionPanel = new Panel();
selectionPanel.setLayout(new BorderLayout());
selectionPanel.add(new Label("Demo", Label.CENTER), BorderLayout.NORTH);
Button fullScreen = new Button("Fullscreen");
fullScreen.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
toggleFullscreen();
}
});
selectionPanel.add(fullScreen, BorderLayout.SOUTH);
final List demos = new List();
for (Enumeration e = selectableDemos.keys(); e.hasMoreElements(); ) {
demos.add(e.nextElement().toString());
}
selectionPanel.add(demos, BorderLayout.CENTER);
demos.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent event) {
demoSelected(event.getItemSelectable().getSelectedObjects()[0].toString());
}
});
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.weightx = 0.05;
gbc.weighty = 1.0;
add(selectionPanel, gbc);
// =================================
try {
demoCanvas = new DemoBoxGLCanvas(this);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.weightx = 0.95;
gbc.weighty = 1.0;
add(demoCanvas, gbc);
} catch (LWJGLException le) {
le.printStackTrace();
return false;
}
// ---------------------------------
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
demoCanvas.destroyCanvas();
dispose();
System.exit(0);
}
});
//demoSelected(demos.getSelectedItem());
return true;
}
use of java.awt.event.WindowAdapter in project intellij-community by JetBrains.
the class IdeFrameImpl method setupCloseAction.
private void setupCloseAction() {
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter() {
public void windowClosing(@NotNull final WindowEvent e) {
if (isTemporaryDisposed())
return;
final Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
if (openProjects.length > 1 || openProjects.length == 1 && SystemInfo.isMacSystemMenu) {
if (myProject != null && myProject.isOpen()) {
ProjectUtil.closeAndDispose(myProject);
}
ApplicationManager.getApplication().getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).projectFrameClosed();
WelcomeFrame.showIfNoProjectOpened();
} else {
ApplicationManagerEx.getApplicationEx().exit();
}
}
});
}
use of java.awt.event.WindowAdapter in project aima-java by aimacode.
the class MonteCarloLocalizationApp method constructBasicApplicationFrame.
/**
* Creates the {@code JFrame} for the application. A window listener is registered.
* @return the main frame of the application.
*/
public JFrame constructBasicApplicationFrame() {
JFrame frame = app.constructApplicationFrame();
frame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
robotGui.saveSettings(settingsGui);
if (settingsFile != null)
settingsGui.saveSettings(settingsFile);
robotGui.destructRobot();
}
});
return frame;
}
Aggregations