List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:com.diversityarrays.kdxplore.field.TrialLayoutEditorDialog.java
static public void main(String[] args) { TrialLayout tl = new TrialLayout(); tl.setOrientation(Orientation.HORIZONTAL); tl.setOrigin(Origin.UPPER_LEFT);//from w w w .j a v a 2 s . c om tl.setTraversal(Traversal.TWO_WAY); tl.setRunLength(5); tl.setOriginPlotId(1); IntRange x = new IntRange(); IntRange y = new IntRange(); IntRange p = new IntRange(); List<PlotName> plotNames = new ArrayList<>(); String rname; rname = "test-xy.txt"; rname = "test-xyp.txt"; // rname = "test-maize.txt"; // rname = "test-p.txt"; InputStream is = TrialLayoutEditorDialog.class.getResourceAsStream(rname); addPlotNames(plotNames, is); for (PlotName pn : plotNames) { Integer plotId = pn.getPlotId(); if (plotId != null) { p.add(plotId); } Integer xx = pn.getX(); if (xx != null) { x.add(xx); } Integer yy = pn.getY(); if (yy != null) { y.add(yy); } } PlotIdentSummary pis = new PlotIdentSummary(p, x, y); PlotIdentOption pio = null; if (p.isEmpty()) { if (!x.isEmpty() && !y.isEmpty()) { pio = PlotIdentOption.X_THEN_Y; } } else { if (x.isEmpty()) { if (y.isEmpty()) { pio = PlotIdentOption.PLOT_ID; } else { pio = PlotIdentOption.PLOT_ID_THEN_Y; } } else if (y.isEmpty()) { pio = PlotIdentOption.PLOT_ID_THEN_X; } else { pio = PlotIdentOption.PLOT_ID_THEN_XY; } } Trial trial = new Trial(); trial.setTrialName("TEST TRIAL"); trial.setPlotIdentSummary(pis); trial.setPlotIdentOption(pio); trial.setTrialLayout(tl); TrialLayoutEditorDialog editor = new TrialLayoutEditorDialog(null, "Trial Layout Editor"); editor.setTrial(trial, plotNames); // editor.setDefaultCloseOperation(EXIT_ON_CLOSE); editor.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { System.out.println("TRialLayout=" + editor.trialLayout); System.exit(0); } }); editor.setVisible(true); }
From source file:CustomIconDemo.java
public static void main(String[] args) { JFrame frame = new JFrame("CustomIconDemo"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from www . ja v a2 s .c om*/ } }); frame.getContentPane().add(new CustomIconDemo(), BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { final JFrame jf = new JFrame("JIFrameDemo Main Window"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); screenSize.width -= 42;//from w w w. jav a 2 s . c o m screenSize.height -= 42; jf.setSize(screenSize); jf.setLocation(20, 20); JMenuBar mb = new JMenuBar(); jf.setJMenuBar(mb); JMenu fm = new JMenu("File"); mb.add(fm); JMenuItem mi; fm.add(mi = new JMenuItem("Exit")); mi.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); JDesktopPane dtp = new JDesktopPane(); //dtp.setBackground(Color.GREEN); jf.setContentPane(dtp); JInternalFrame mboxFrame = new JInternalFrame("Mail Reader", true, true, true, true); JLabel reader = new JLabel("Mail Reader Would Be Here"); mboxFrame.setContentPane(reader); mboxFrame.setSize(400, 300); mboxFrame.setLocation(50, 50); mboxFrame.setVisible(true); dtp.add(mboxFrame); JInternalFrame compFrame = new JInternalFrame("Compose Mail", true, true, true, true); JLabel composer = new JLabel("Mail Compose Would Be Here"); compFrame.setContentPane(composer); compFrame.setSize(300, 200); compFrame.setLocation(200, 200); compFrame.setVisible(true); dtp.add(compFrame); JInternalFrame listFrame = new JInternalFrame("Users", true, true, true, true); JLabel list = new JLabel("List of Users Would Be Here"); listFrame.setContentPane(list); listFrame.setLocation(400, 400); listFrame.setSize(500, 200); listFrame.setVisible(true); dtp.add(listFrame); jf.setVisible(true); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { jf.setVisible(false); jf.dispose(); System.exit(0); } }); }
From source file:UndoExample3.java
public static void main(String[] args) { try {//from ww w .ja v a2s.c o m UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new UndoExample3(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); f.pack(); f.setVisible(true); }
From source file:MyButtonUI.java
public static void main(String argv[]) { JFrame f = new JFrame(); f.setSize(400, 300);/* w ww . j a v a 2s. c o m*/ f.getContentPane().setLayout(new FlowLayout()); JPanel p = new JPanel(); JButton bt1 = new JButton("Click Me"); bt1.setUI(new MyButtonUI()); p.add(bt1); f.getContentPane().add(p); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; f.addWindowListener(wndCloser); f.setVisible(true); }
From source file:UndoExample4.java
public static void main(String[] args) { try {/*from w ww . j a va 2 s .com*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new UndoExample4(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); f.pack(); f.setVisible(true); }
From source file:JumbledImage.java
public static void main(String s[]) { JFrame f = new JFrame("Jumbled Image"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);// w ww. j a va 2s. c o m } }); URL imageSrc = null; try { imageSrc = ((new File(imageFileName)).toURI()).toURL(); } catch (MalformedURLException e) { } JumbledImageApplet jumbler = new JumbledImageApplet(imageSrc); jumbler.buildUI(); f.add("Center", jumbler); f.pack(); f.setVisible(true); }
From source file:EditorPaneExample4.java
public static void main(String[] args) { try {/*from www . j av a 2 s . c o m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new EditorPaneExample4(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); f.setSize(500, 400); f.setVisible(true); }
From source file:PaginationExample.java
public static void main(String args[]) { try {//from w w w .jav a 2 s . c o m String cn = UIManager.getSystemLookAndFeelClassName(); UIManager.setLookAndFeel(cn); // Use the native L&F } catch (Exception cnf) { } JFrame f = new JFrame("Printing Pagination Example"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JButton printButton = new JButton("Print Pages"); printButton.addActionListener(new PaginationExample()); f.add("Center", printButton); f.pack(); f.setVisible(true); }
From source file:fll.subjective.SubjectiveFrame.java
public static void main(final String[] args) { LogUtils.initializeLogging();/*from w ww . j a v a 2 s. c o m*/ Thread.setDefaultUncaughtExceptionHandler(new GuiExceptionHandler()); // Use cross platform look and feel so that things look right all of the // time try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (final ClassNotFoundException e) { LOGGER.warn("Could not find cross platform look and feel class", e); } catch (final InstantiationException e) { LOGGER.warn("Could not instantiate cross platform look and feel class", e); } catch (final IllegalAccessException e) { LOGGER.warn("Error loading cross platform look and feel", e); } catch (final UnsupportedLookAndFeelException e) { LOGGER.warn("Cross platform look and feel unsupported?", e); } try { final SubjectiveFrame frame = new SubjectiveFrame(); frame.addWindowListener(new WindowAdapter() { @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void windowClosing(final WindowEvent e) { System.exit(0); } @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void windowClosed(final WindowEvent e) { System.exit(0); } }); // should be able to watch for window closing, but hidden works frame.addComponentListener(new ComponentAdapter() { @Override @SuppressFBWarnings(value = { "DM_EXIT" }, justification = "Exiting from main is OK") public void componentHidden(final ComponentEvent e) { System.exit(0); } }); GraphicsUtils.centerWindow(frame); frame.setVisible(true); frame.promptForFile(); } catch (final Throwable e) { JOptionPane.showMessageDialog(null, "Unexpected error: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); LOGGER.fatal("Unexpected error", e); System.exit(1); } }