Example usage for java.awt.event WindowAdapter WindowAdapter

List of usage examples for java.awt.event WindowAdapter WindowAdapter

Introduction

In this page you can find the example usage for java.awt.event WindowAdapter WindowAdapter.

Prototype

WindowAdapter

Source Link

Usage

From source file:EditorPaneExample9.java

public static void main(String[] args) {
    try {//from ww w .  jav a  2 s  .c  o  m
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JFrame f = new EditorPaneExample9();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
    f.setSize(500, 400);
    f.setVisible(true);
}

From source file:ImageDrawingComponent.java

public static void main(String s[]) {
    JFrame f = new JFrame("ImageDrawing");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   w  w  w.j  a  v a 2s .c o m
        }
    });
    URL imageSrc = null;
    try {
        imageSrc = ((new File(imageFileName)).toURI()).toURL();
    } catch (MalformedURLException e) {
    }
    ImageDrawingApplet id = new ImageDrawingApplet(imageSrc);
    id.buildUI();
    f.add("Center", id);
    f.pack();
    f.setVisible(true);
}

From source file:CompositeEffects.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from   www  . jav a2 s .  com*/
        }
    });
    f.setContentPane(new CompositeEffects());
    f.setSize(700, 250);
    f.setVisible(true);
}

From source file:DOMTreeWalkerTreeModel.java

/**
 * This main() method demonstrates the use of this class, the use of the
 * Xerces DOM parser, and the creation of a DOM Level 2 TreeWalker object.
 *//* ww w .j  a  v a 2  s.  co m*/
public static void main(String[] args) throws IOException, SAXException {
    // Obtain an instance of a Xerces parser to build a DOM tree.
    // Note that we are not using the JAXP API here, so this
    // code uses Apache Xerces APIs that are not standards
    DOMParser parser = new org.apache.xerces.parsers.DOMParser();

    // Get a java.io.Reader for the input XML file and
    // wrap the input file in a SAX input source
    Reader in = new BufferedReader(new FileReader(args[0]));
    InputSource input = new org.xml.sax.InputSource(in);

    // Tell the Xerces parser to parse the input source
    parser.parse(input);

    // Ask the parser to give us our DOM Document. Once we've got the DOM
    // tree, we don't have to use the Apache Xerces APIs any more; from
    // here on, we use the standard DOM APIs
    Document document = parser.getDocument();

    // If we're using a DOM Level 2 implementation, then our Document
    // object ought to implement DocumentTraversal
    DocumentTraversal traversal = (DocumentTraversal) document;

    // For this demonstration, we create a NodeFilter that filters out
    // Text nodes containing only space; these just clutter up the tree
    NodeFilter filter = new NodeFilter() {
        public short acceptNode(Node n) {
            if (n.getNodeType() == Node.TEXT_NODE) {
                // Use trim() to strip off leading and trailing space.
                // If nothing is left, then reject the node
                if (((Text) n).getData().trim().length() == 0)
                    return NodeFilter.FILTER_REJECT;
            }
            return NodeFilter.FILTER_ACCEPT;
        }
    };

    // This set of flags says to "show" all node types except comments
    int whatToShow = NodeFilter.SHOW_ALL & ~NodeFilter.SHOW_COMMENT;

    // Create a TreeWalker using the filter and the flags
    TreeWalker walker = traversal.createTreeWalker(document, whatToShow, filter, false);

    // Instantiate a TreeModel and a JTree to display it
    JTree tree = new JTree(new DOMTreeWalkerTreeModel(walker));

    // Create a frame and a scrollpane to display the tree, and pop them up
    JFrame frame = new JFrame("DOMTreeWalkerTreeModel Demo");
    frame.getContentPane().add(new JScrollPane(tree));
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    frame.setSize(500, 250);
    frame.setVisible(true);
}

From source file:ListInput.java

public static void main(String[] a) {
    String[] fontNames = new String[] { "Roman", "Times Roman" };
    ListInput lstFontName = new ListInput(fontNames, "Name:");
    lstFontName.setDisplayedMnemonic('n');
    lstFontName.setToolTipText("Font name");
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  w  ww .  ja  va 2s . c  om*/
        }
    });
    f.getContentPane().add(lstFontName);
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.show();

}

From source file:SimpleDateFormatDemo.java

public static void main(String s[]) {
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from w  w w.  j a v a 2  s .  co m*/
        }
    };

    frame = new JFrame("Date Formatting Demo");
    frame.addWindowListener(l);
    frame.getContentPane().add("Center", new SimpleDateFormatDemo());
    frame.pack();
    frame.setVisible(true);
}

From source file:MessageMonitor.java

/** Main program entry point. */
public static void main(String[] args) {
    // There should be no arguments to this program.
    if (args.length > 0) {
        printUsage();//from  w ww . ja  va2 s.  c  o m
        System.exit(1);
    }

    MessageMonitor messageMonitor = new MessageMonitor();

    messageMonitor.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    screenSize.height = screenSize.height / 2;
    screenSize.width = screenSize.width / 2;
    messageMonitor.setSize(screenSize);
    messageMonitor.setVisible(true);

}

From source file:com.djimenez.tuenti.example.ClientApp.java

public static void main(final String[] args) {
    final HttpClientFrame f = new HttpClientFrame();
    f.setTitle("HttpClient demo application");

    final int width = 700;
    final int height = 500;
    f.setSize(width, height);//from   w ww  .  ja  v a  2s.c  o  m

    f.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(final WindowEvent e) {
            System.exit(0);
        }
    });
    f.setVisible(true);
}

From source file:EditorPaneExample7.java

public static void main(String[] args) {
    try {/*from w ww  .  ja  va  2 s.c  o  m*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JFrame f = new EditorPaneExample7();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
    f.setSize(500, 400);
    f.setVisible(true);
}

From source file:Accounts.java

public static void main(String[] args) {
    Accounts accounts = new Accounts();

    accounts.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from  www  .j av a  2  s  .c o m
        }
    });

    accounts.init();
    accounts.buildGUI();
}