use of java.awt.event.WindowAdapter in project ACS by ACS-Community.
the class SysPropEditor method openFrame.
public static JFrame openFrame(final SysPropEditor inst) {
// frame
final JFrame f = new JFrame(SysPropEditor.class.getName());
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
int answer = JOptionPane.showConfirmDialog(f, "Really close?", "Close Window", JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION) {
f.setVisible(false);
f.dispose();
}
}
});
f.getContentPane().add(inst);
f.pack();
f.setVisible(true);
return f;
}
use of java.awt.event.WindowAdapter in project ACS by ACS-Community.
the class LogManagerGui method openFrame.
//
// ============= Stand-Alone Launch==================
//
public static JFrame openFrame(final LogManagerGui inst) {
// frame
final JFrame f = new JFrame(LogManagerGui.class.getName());
f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent evt) {
int answer = JOptionPane.showConfirmDialog(f, "Really close?", "Close Window", JOptionPane.YES_NO_OPTION);
if (answer == JOptionPane.YES_OPTION) {
f.setVisible(false);
f.dispose();
}
}
});
f.getContentPane().add(inst);
f.pack();
f.setVisible(true);
return f;
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class NoResizeEventOnDMChangeTest method testFSWindow.
private static void testFSWindow(final GraphicsDevice gd, final DisplayMode[] dms, final Window fsWin) {
System.out.println("Testing FS window: " + fsWin);
Component c = new Canvas() {
@Override
public void paint(Graphics g) {
g.setColor(Color.blue);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.magenta);
g.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
g.setColor(Color.red);
g.drawString("FS Window : " + fsWin, 50, 50);
DisplayMode dm = getGraphicsConfiguration().getDevice().getDisplayMode();
g.drawString("Display Mode: " + dm.getWidth() + "x" + dm.getHeight(), 50, 75);
}
};
fsWin.add("Center", c);
fsWin.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
fsWin.dispose();
if (fsWin.getOwner() != null) {
fsWin.getOwner().dispose();
}
}
});
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
gd.setFullScreenWindow(fsWin);
}
});
} catch (Exception ex) {
}
sleep(1000);
final ResizeEventChecker r1 = new ResizeEventChecker();
final ResizeEventChecker r2 = new ResizeEventChecker();
if (gd.isDisplayChangeSupported()) {
fsWin.addComponentListener(r1);
c.addComponentListener(r2);
for (final DisplayMode dm1 : dms) {
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
System.err.printf("----------- Setting DM %dx%d:\n", dm1.getWidth(), dm1.getHeight());
try {
gd.setDisplayMode(dm1);
r1.incDmChanges();
r2.incDmChanges();
} catch (IllegalArgumentException iae) {
}
}
});
} catch (Exception ex) {
}
for (int i = 0; i < 3; i++) {
fsWin.repaint();
sleep(1000);
}
}
fsWin.removeComponentListener(r1);
c.removeComponentListener(r2);
}
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
gd.setFullScreenWindow(null);
fsWin.dispose();
if (fsWin.getOwner() != null) {
fsWin.getOwner().dispose();
}
}
});
} catch (Exception ex) {
}
System.out.printf("FS Window: resizes=%d, dm changes=%d\n", r1.getResizes(), r1.getDmChanges());
System.out.printf("Component: resizes=%d, dm changes=%d\n", r2.getResizes(), r2.getDmChanges());
if (r1.getResizes() < r1.getDmChanges()) {
throw new RuntimeException("FS Window didn't receive all resizes!");
}
if (r2.getResizes() < r2.getDmChanges()) {
throw new RuntimeException("Component didn't receive all resizes!");
}
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class TooMuchWheelRotationEventsTest method createUI.
private static void createUI() {
final JFrame mainFrame = new JFrame("Trackpad scrolling test");
GridBagLayout layout = new GridBagLayout();
JPanel mainControlPanel = new JPanel(layout);
JPanel resultButtonPanel = new JPanel(layout);
GridBagConstraints gbc = new GridBagConstraints();
JPanel testPanel = createTestPanel();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(testPanel, gbc);
JTextArea instructionTextArea = new JTextArea();
instructionTextArea.setText(INSTRUCTIONS);
instructionTextArea.setEditable(false);
instructionTextArea.setBackground(Color.white);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
mainControlPanel.add(instructionTextArea, gbc);
JButton passButton = new JButton("Pass");
passButton.setActionCommand("Pass");
passButton.addActionListener((ActionEvent e) -> {
testResult = true;
mainFrame.dispose();
countDownLatch.countDown();
});
JButton failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
gbc.gridx = 0;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(failButton, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
mainControlPanel.add(resultButtonPanel, gbc);
mainFrame.add(mainControlPanel);
mainFrame.pack();
mainFrame.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
mainFrame.dispose();
countDownLatch.countDown();
}
});
mainFrame.setVisible(true);
}
use of java.awt.event.WindowAdapter in project jdk8u_jdk by JetBrains.
the class TexturePaintPrintingTest method doTest.
private static void doTest(Runnable action) {
String description = " A TexturePaint graphics will be shown on console.\n" + " The same graphics is sent to printer.\n" + " Please verify if TexturePaint shading is printed.\n" + " If none is printed, press FAIL else press PASS";
final JDialog dialog = new JDialog();
dialog.setTitle("printSelectionTest");
JTextArea textArea = new JTextArea(description);
textArea.setEditable(false);
final JButton testButton = new JButton("Start Test");
final JButton passButton = new JButton("PASS");
passButton.setEnabled(false);
passButton.addActionListener((e) -> {
f.dispose();
dialog.dispose();
pass();
});
final JButton failButton = new JButton("FAIL");
failButton.setEnabled(false);
failButton.addActionListener((e) -> {
f.dispose();
dialog.dispose();
fail();
});
testButton.addActionListener((e) -> {
testButton.setEnabled(false);
action.run();
passButton.setEnabled(true);
failButton.setEnabled(true);
});
JPanel mainPanel = new JPanel(new BorderLayout());
mainPanel.add(textArea, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout());
buttonPanel.add(testButton);
buttonPanel.add(passButton);
buttonPanel.add(failButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
dialog.add(mainPanel);
dialog.pack();
dialog.setVisible(true);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.out.println("main dialog closing");
testGeneratedInterrupt = false;
mainThread.interrupt();
}
});
}
Aggregations