List of usage examples for java.awt.event WindowAdapter WindowAdapter
WindowAdapter
From source file:AreaAdd.java
public static void main(String s[]) { JFrame f = new JFrame("Pear"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from w w w . j a va 2s . c o m } }); JApplet applet = new AreaAdd(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(150, 200)); f.show(); }
From source file:MulticastEvent.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("MulticastTest"); frame.setSize(300, 200);//from w w w.ja v a 2 s . c o m frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = frame.getContentPane(); contentPane.add(new MulticastEvent()); frame.show(); }
From source file:ShapeMover.java
public static void main(String s[]) { Frame f = new Frame("ShapeMover"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);// w w w .j a v a2 s . c o m } }); Applet applet = new ShapeMover(); f.add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(550, 250)); f.show(); }
From source file:FillRectPanel.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("FillRect"); frame.setSize(300, 200);/*w w w. j a v a 2 s . co m*/ frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container contentPane = frame.getContentPane(); contentPane.add(new FillRectPanel()); frame.show(); }
From source file:GridBagWithGridWidthHeight.java
public static void main(String[] args) { JFrame f = new JFrame("Demonstrates the use of gridwidth, gridheight constraints"); JPanel p = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 2, 2); c.weighty = 1.0;/*from ww w . j a v a2s . co m*/ c.weightx = 1.0; c.gridx = 0; c.gridy = 0; c.gridheight = 2; // span across 2 rows p.add(new JButton("Java"), c); c.gridx = 1; c.gridheight = 1; // set back to 1 row c.gridwidth = 2; // span across 2 columns p.add(new JButton("Source"), c); c.gridy = 1; c.gridwidth = 1; // set back to 1 column p.add(new JButton("and"), c); c.gridx = 2; 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(); }
From source file:LineDemo2D.java
public static void main(String s[]) { JFrame f = new JFrame("ShapesDemo2D"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);//from ww w . ja va 2 s .c om } }); JApplet applet = new LineDemo2D(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }
From source file:ColorAction.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setTitle("SeparateGUITest"); frame.setSize(300, 200);/*from w ww.ja va2 s.com*/ frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JPanel panel = new JPanel(); Action blueAction = new ColorAction("Blue", new ImageIcon("blue-ball.gif"), Color.blue, panel); Action yellowAction = new ColorAction("Yellow", new ImageIcon("yellow-ball.gif"), Color.yellow, panel); Action redAction = new ColorAction("Red", new ImageIcon("red-ball.gif"), Color.red, panel); panel.add(new JButton(yellowAction)); panel.add(new JButton(blueAction)); panel.add(new JButton(redAction)); panel.registerKeyboardAction(yellowAction, KeyStroke.getKeyStroke(KeyEvent.VK_Y, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); panel.registerKeyboardAction(blueAction, KeyStroke.getKeyStroke(KeyEvent.VK_B, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); panel.registerKeyboardAction(redAction, KeyStroke.getKeyStroke(KeyEvent.VK_R, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); Container contentPane = frame.getContentPane(); contentPane.add(panel); JMenu m = new JMenu("Color"); m.add(yellowAction); m.add(blueAction); m.add(redAction); JMenuBar mbar = new JMenuBar(); mbar.add(m); frame.setJMenuBar(mbar); frame.show(); }
From source file:BorderLayoutPane.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 . jav a 2 s . c o m } }); f.setContentPane(new BorderLayoutPane()); f.pack(); f.setVisible(true); }
From source file:ColorPan.java
public static void main(String[] args) { JFrame f = new JFrame("ColorPan"); f.getContentPane().add(new ColorPan()); f.setSize(300, 300);/*from w w w . j av a 2 s. co m*/ f.setLocation(100, 100); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); }
From source file:FilledArc.java
public static void main(String s[]) { JFrame f = new JFrame(""); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*from www. java2s .c o m*/ } }); JApplet applet = new FilledArc(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(300, 300)); f.show(); }