View Javadoc
1 /* 2 * Created on Sep 19, 2003 3 * Copyright (c) 2003 William Lee. All rights reserved. 4 */ 5 package portaview; 6 7 import java.awt.Dimension; 8 import java.awt.Toolkit; 9 import java.awt.event.WindowAdapter; 10 import java.awt.event.WindowEvent; 11 12 import javax.swing.JFrame; 13 14 /*** 15 * The basic frame that is the parent of all frames. 16 * @author <a href="mailto:wwlee1@uiuc.edu">William Lee</a> 17 * @version $Id: DefaultFrame.java,v 1.4 2003/12/10 06:18:57 wlee Exp $ 18 */ 19 public class DefaultFrame extends JFrame 20 { 21 22 /*** 23 * Constructs the default frame with a name 24 * @param name name of frame. 25 */ 26 public DefaultFrame(String name) 27 { 28 super(name); 29 setDefaultWindowAdapter(); 30 } 31 32 /*** 33 * Constructs the default frame 34 */ 35 public DefaultFrame() 36 { 37 this(null); 38 } 39 40 /*** 41 * Position the window in the center of the display. 42 */ 43 protected void center() 44 { 45 Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); 46 setLocation( 47 d.width / 2 - getWidth() / 2, 48 d.height / 2 - getHeight() / 2); 49 } 50 51 /*** 52 * Generates a new WindowAdapter that closes the application. 53 * @return a window listener that just call System.exit(0); 54 */ 55 protected WindowAdapter getDefaultWindowAdapter() 56 { 57 WindowAdapter rtn = (new WindowAdapter() 58 { 59 public void windowClosing(WindowEvent e) 60 { 61 System.exit(0); 62 } 63 64 public void windowDeiconified(WindowEvent e) 65 { 66 } 67 68 public void windowIconified(WindowEvent e) 69 { 70 } 71 }); 72 return rtn; 73 } 74 75 /*** 76 * Set the default window adapater. 77 */ 78 protected void setDefaultWindowAdapter() 79 { 80 this.addWindowListener(getDefaultWindowAdapter()); 81 } 82 83 }

This page was automatically generated by Maven