List of usage examples for javax.swing JFrame addWindowListener
public synchronized void addWindowListener(WindowListener l)
From source file:UsingWindowListener.java
public static void main(String[] args) { JFrame aWindow = new JFrame("This is the Window Title"); aWindow.setBounds(50, 100, 300, 300); aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); aWindow.addWindowListener(new WindowListener() { public void windowIconified(WindowEvent e) { System.out.println(e); }/*from ww w .j a v a 2s . c o m*/ public void windowDeiconified(WindowEvent e) { } public void windowOpened(WindowEvent e) { } public void windowClosing(WindowEvent e) { } public void windowClosed(WindowEvent e) { } public void windowActivated(WindowEvent e) { } public void windowDeactivated(WindowEvent e) { } }); aWindow.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 ww w . jav a 2s . c om*/ } }); f.setContentPane(new ColumnLayoutPane()); f.pack(); f.setVisible(true); }
From source file:WindowAdapterTest.java
public static void main(String args[]) { JFrame frame = new JFrame("Window Listener"); WindowListener listener = new WindowAdapter() { public void windowClosing(WindowEvent w) { System.exit(0);//w w w . j a v a 2s. co m } }; frame.addWindowListener(listener); frame.setSize(300, 300); frame.show(); }
From source file:com.archivas.clienttools.arcmover.gui.panels.CopyOptionsPanel.java
public static void main(String[] args) { // just test this panel. CopyOptionsPanel p = new CopyOptionsPanel(null, new CopyJob()); JFrame f = new JFrame(); f.add(p);//from ww w .j a va 2 s . co m f.pack(); f.setLocation(100, 800); f.setSize(new Dimension(700, 500)); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.setVisible(true); }
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 w w.j a va 2s . c o m } }); frame.pack(); frame.setVisible(true); }
From source file:CustomStrokes.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 . j a v a2 s . co m } }); f.setContentPane(new CustomStrokes()); f.setSize(750, 200); f.setVisible(true); }
From source file:UndoExample3.java
public static void main(String[] args) { try {// w w w .jav a 2 s . c om 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: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);// w ww .j ava 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:HitTestSample.java
public static void main(String[] args) { JFrame f = new JFrame("HitTestSample"); HitTestSample demo = new HitTestSample(); f.getContentPane().add(demo, "Center"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/*ww w. j a v a2 s .c om*/ } }); f.setSize(new Dimension(400, 250)); f.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);/* ww w . j a v a2s. 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); }