List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("Customized Event"); frame.setSize(300, 80);/*from ww w. ja va 2s .c o m*/ frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = frame.getContentPane(); contentPane.add(new Main()); frame.setVisible(true); }
From source file:CustomEventPanel.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("Customized Event"); frame.setSize(300, 80);//from www . jav a 2 s .c om frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = frame.getContentPane(); contentPane.add(new CustomEventPanel()); frame.show(); }
From source file:DrawPolyPanel.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("DrawPoly"); frame.setSize(350, 250);//w w w. j a va 2 s . c om frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = frame.getContentPane(); contentPane.add(new DrawPolyPanel()); frame.show(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { MyFileChooser chooser = new MyFileChooser(); chooser.setDialogType(JFileChooser.SAVE_DIALOG); final JDialog dialog = chooser.createDialog(null); chooser.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent evt) { JFileChooser chooser = (JFileChooser) evt.getSource(); if (JFileChooser.APPROVE_SELECTION.equals(evt.getActionCommand())) { dialog.setVisible(false); } else if (JFileChooser.CANCEL_SELECTION.equals(evt.getActionCommand())) { dialog.setVisible(false); }/*w w w. j a v a2 s .c om*/ } }); dialog.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dialog.setVisible(false); } }); dialog.setVisible(true); }
From source file:AttributesApp.java
public static void main(String arg[]) { JFrame frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from www .j a v a 2 s . c om*/ } }); frame.getContentPane().add("Center", new AttributesApp()); frame.setSize(500, 200); frame.setVisible(true); }
From source file:TexturePaintDemo.java
public static void main(String s[]) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from ww w . j a v a 2 s. com*/ } }); TexturePaintDemo p = new TexturePaintDemo(); f.getContentPane().add("Center", p); p.init(); f.pack(); f.setSize(new Dimension(250, 250)); f.show(); }
From source file:TransformDemo.java
public static void main(String s[]) { 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 .com*/ } }); TransformDemo p = new TransformDemo(); f.getContentPane().add("Center", p); p.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:ColoredToolTipExample.java
public static void main(String args[]) { try {/*from ww w .j a va 2 s . c o m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } ColoredToolTipExample f = new ColoredToolTipExample(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setSize(300, 100); f.show(); }
From source file:AreaSubtract.java
public static void main(String s[]) { JFrame f = new JFrame("Pear"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//w w w. j ava 2 s.c o m } }); JApplet applet = new AreaSubtract(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(150, 200)); f.show(); }
From source file:GridBagWithWeight.java
public static void main(String[] args) { JFrame f = new JFrame("Demonstrates the use of weightx, weighty constraints"); JPanel p = new JPanel(); p.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); p.setLayout(new GridBagLayout()); c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); c.weighty = 1.0;//from www . j a v a2 s . com c.weightx = 1.0; c.gridx = 0; c.gridy = 0; p.add(new JButton("Java"), c); c.gridx = 1; p.add(new JButton("Source"), c); c.gridx = 0; c.gridy = 1; p.add(new JButton("and"), c); c.gridx = 1; p.add(new JButton("Support."), c); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; f.addWindowListener(wndCloser); f.getContentPane().add(p); f.setSize(600, 200); f.show(); }