List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:CutAndPasteDemo.java
public static void main(String[] args) { JFrame frame = new CutAndPasteDemo(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w ww . j av a 2 s .c o m } }); frame.pack(); frame.setVisible(true); }
From source file:FileViewer.java
/** * The FileViewer can be used by other classes, or it can be used standalone * with this main() method.//from w w w . j a v a2s .co m */ static public void main(String[] args) throws IOException { // Create a FileViewer object Frame f = new FileViewer((args.length == 1) ? args[0] : null); // Arrange to exit when the FileViewer window closes f.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { System.exit(0); } }); // And pop the window up f.show(); }
From source file:SimplelookandfeelExample.java
public static void main(String s[]) { /* /*from w w w.j av a 2 s .c o m*/ NOTE: By default, the look and feel will be set to the Cross Platform Look and Feel (which is currently Metal). The user may someday be able to override the default via a system property. If you as the developer want to be sure that a particular L&F is set, you can do so by calling UIManager.setLookAndFeel(). For example, the first code snippet below forcibly sets the UI to be the System Look and Feel. The second code snippet forcibly sets the look and feel to the Cross Platform L&F. Snippet 1: try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception exc) { System.err.println("Error loading L&F: " + exc); } Snippet 2: try { UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); } catch (Exception exc) { System.err.println("Error loading L&F: " + exc); } */ SimpleExample panel = new SimpleExample(); frame = new JFrame("SimpleExample"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.getContentPane().add("Center", panel); frame.pack(); frame.setVisible(true); panel.updateState(); }
From source file:ImageOps.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from w w w.j a v a 2 s.c o m*/ } }); f.setContentPane(new ImageOps()); f.pack(); f.setVisible(true); }
From source file:core.PlanC.java
/** * inicio de aplicacion//from w w w . j a v a2 s .c om * * @param arg - argumentos de entrada */ public static void main(String[] args) { // user.name /* * Properties prp = System.getProperties(); System.out.println(getWmicValue("bios", "SerialNumber")); * System.out.println(getWmicValue("cpu", "SystemName")); */ try { // log // -Djava.util.logging.SimpleFormatter.format='%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s %2$s %5$s%6$s%n' // System.setProperty("java.util.logging.SimpleFormatter.format", // "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %4$s %2$s %5$s%6$s%n"); System.setProperty("java.util.logging.SimpleFormatter.format", "%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS %5$s%6$s%n"); FileHandler fh = new FileHandler(LOG_FILE); fh.setFormatter(new SimpleFormatter()); fh.setLevel(Level.INFO); ConsoleHandler ch = new ConsoleHandler(); ch.setFormatter(new SimpleFormatter()); ch.setLevel(Level.INFO); logger = Logger.getLogger(""); Handler[] hs = logger.getHandlers(); for (int x = 0; x < hs.length; x++) { logger.removeHandler(hs[x]); } logger.addHandler(fh); logger.addHandler(ch); // point apache log to this log System.setProperty("org.apache.commons.logging.Log", Jdk14Logger.class.getName()); TPreferences.init(); TStringUtils.init(); Font fo = Font.createFont(Font.TRUETYPE_FONT, TResourceUtils.getFile("Dosis-Light.ttf")); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(fo); fo = Font.createFont(Font.TRUETYPE_FONT, TResourceUtils.getFile("Dosis-Medium.ttf")); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(fo); fo = Font.createFont(Font.TRUETYPE_FONT, TResourceUtils.getFile("AERO_ITALIC.ttf")); GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(fo); SwingTimerTimingSource ts = new SwingTimerTimingSource(); AnimatorBuilder.setDefaultTimingSource(ts); ts.init(); // parse app argument parameters and append to tpreferences to futher uses for (String arg : args) { String[] kv = arg.split("="); TPreferences.setProperty(kv[0], kv[1]); } RUNNING_MODE = TPreferences.getProperty("runningMode", RM_NORMAL); newMsg = Applet.newAudioClip(TResourceUtils.getURL("newMsg.wav")); } catch (Exception e) { SystemLog.logException1(e, true); } // pass icon from metal to web look and feel Icon i1 = UIManager.getIcon("OptionPane.errorIcon"); Icon i2 = UIManager.getIcon("OptionPane.informationIcon"); Icon i3 = UIManager.getIcon("OptionPane.questionIcon"); Icon i4 = UIManager.getIcon("OptionPane.warningIcon"); // Object fcui = UIManager.get("FileChooserUI"); // JFileChooser fc = new JFileChooser(); WebLookAndFeel.install(); // WebLookAndFeel.setDecorateFrames(true); // WebLookAndFeel.setDecorateDialogs(true); UIManager.put("OptionPane.errorIcon", i1); UIManager.put("OptionPane.informationIcon", i2); UIManager.put("OptionPane.questionIcon", i3); UIManager.put("OptionPane.warningIcon", i4); // UIManager.put("TFileChooserUI", fcui); // warm up the IDW. // in my computer, some weird error ocurr if i don't execute this preload. new RootWindow(null); frame = new TWebFrame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { Exit.shutdown(); } }); if (RUNNING_MODE.equals(RM_NORMAL)) { initEnviorement(); } if (RUNNING_MODE.equals(RM_CONSOLE)) { initConsoleEnviorement(); } if (RUNNING_MODE.equals(ONE_TASK)) { String cln = TPreferences.getProperty("taskName", "*TaskNotFound"); PlanC.logger.log(Level.INFO, "OneTask parameter found in .properties. file Task name = " + cln); try { Class cls = Class.forName(cln); Object dobj = cls.newInstance(); // new class must be extends form AbstractExternalTask TTaskManager.executeTask((Runnable) dobj); return; } catch (Exception e) { PlanC.logger.log(Level.SEVERE, e.getMessage(), e); Exit.shutdown(); } } }
From source file:Paints.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w w w . ja v a2 s.c o m } }); f.setContentPane(new Paints()); f.setSize(800, 375); f.setVisible(true); }
From source file:ComponentTree.java
/** * This main() method demonstrates the use of the ComponentTree class: it * puts a ComponentTree component in a Frame, and uses the ComponentTree to * display its own GUI hierarchy. It also adds a TreeSelectionListener to * display additional information about each component as it is selected */// w ww. ja v a 2 s . co m public static void main(String[] args) { // Create a frame for the demo, and handle window close requests JFrame frame = new JFrame("ComponentTree Demo"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); // Create a scroll pane and a "message line" and add them to the // center and bottom of the frame. JScrollPane scrollpane = new JScrollPane(); final JLabel msgline = new JLabel(" "); frame.getContentPane().add(scrollpane, BorderLayout.CENTER); frame.getContentPane().add(msgline, BorderLayout.SOUTH); // Now create the ComponentTree object, specifying the frame as the // component whose tree is to be displayed. Also set the tree's font. JTree tree = new ComponentTree(frame); tree.setFont(new Font("SansSerif", Font.BOLD, 12)); // Only allow a single item in the tree to be selected at once tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); // Add an event listener for notifications when // the tree selection state changes. tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent e) { // Tree selections are referred to by "path" // We only care about the last node in the path TreePath path = e.getPath(); Component c = (Component) path.getLastPathComponent(); // Now we know what component was selected, so // display some information about it in the message line if (c.isShowing()) { Point p = c.getLocationOnScreen(); msgline.setText("x: " + p.x + " y: " + p.y + " width: " + c.getWidth() + " height: " + c.getHeight()); } else { msgline.setText("component is not showing"); } } }); // Now that we've set up the tree, add it to the scrollpane scrollpane.setViewportView(tree); // Finally, set the size of the main window, and pop it up. frame.setSize(600, 400); frame.setVisible(true); }
From source file:SaveImage.java
public static void main(String s[]) { JFrame f = new JFrame("Save Image Sample"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/* w ww .j a v a 2s .c o m*/ } }); SaveImage si = new SaveImage(); f.add("Center", si); JComboBox choices = new JComboBox(si.getDescriptions()); choices.setActionCommand("SetFilter"); choices.addActionListener(si); JComboBox formats = new JComboBox(si.getFormats()); formats.setActionCommand("Formats"); formats.addActionListener(si); JPanel panel = new JPanel(); panel.add(choices); panel.add(new JLabel("Save As")); panel.add(formats); f.add("South", panel); f.pack(); f.setVisible(true); }
From source file:AccessibleScrollDemo.java
public static void main(String s[]) { JFrame frame = new JFrame("AccessibleScrollDemo"); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w w w .java 2 s .co m } }); frame.setContentPane(new AccessibleScrollDemo()); frame.pack(); frame.setVisible(true); }
From source file:ColumnLayout.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from w w w. j av a 2 s . c om*/ } }); f.setContentPane(new ColumnLayoutPane()); f.pack(); f.setVisible(true); }