001    /*
002     * ResetMenu.java 
003     * Part of the Spirograph problem set
004     *
005     * Developed for "Rethinking CS101", a project of Lynn Andrea Stein's AP Group.
006     * For more information, see <a href="http://www.ai.mit.edu/projects/cs101/">the
007     * CS101 homepage</a> or email <las@ai.mit.edu>.
008     *
009     * Copyright (C) 1996 Massachusetts Institute of Technology.
010     * Please do not redistribute without obtaining permission.
011     */
012    
013    package spirograph;
014    
015    import java.awt.*;
016    import java.awt.event.*;
017    
018    /** This class creates a pop up menu that allows the user to reset different
019     * things. All of the event handlers are passed from the DotFrame.
020     *
021     * <p>Copyright © 1998 Massachusetts Institute of Technology<br />
022     * Copyright © 2003 Franklin W. Olin College of Engineering</p>
023     *
024     * @author Luis Sarmenta, lfgs@cag.lcs.mit.edu
025     * @author Henry Wong, henryw@mit.edu
026     * @author Patrick G. Heck, gus.heck@olin.edu
027     * @version $Id: ResetMenu.java,v 1.4 2003/01/17 18:40:22 gus Exp $
028     * @see RecipieView
029     */
030    public class ResetMenu extends Frame {
031        Button lines = new Button("Click here to clear lines.");
032        Button grav = new Button ("Click here to clear the gravity sources.");
033        Button pos = new Button("Click here to stop the ball and move it " +
034                                 "back to the center.");
035        Button all = new Button("Click here to do all of the above.");
036        
037        /** Create a new <code>ResetMenu</code> with the default font.
038         */    
039        public ResetMenu() {
040            this(Spirograph.DEFAULTFONT);
041        }
042    
043        // I use containers and a grid layout so that the bottom button will
044        // span the entire width of the window. Doing it this way is easier
045        // than using a GridBagLayout
046        
047        /** Create a new <code>ResetMenu</code> with the specified <code>Font</code>.
048         * @param f The desired <code>Font</code>
049         */    
050        public ResetMenu(Font f) {
051    
052            this.setFont(f);
053            this.setTitle("Reset Menu");
054            this.setLayout(new GridLayout(4,1));
055            this.add(lines);
056            this.add(grav);
057            this.add(pos);
058            this.add(all);
059    
060            addWindowListener(new java.awt.event.WindowAdapter() {
061                public void windowClosing(java.awt.event.WindowEvent evt) {
062                    exitForm(evt);
063                }
064            });
065    
066            this.pack();
067        }
068        /** Exit the Application */
069        private void exitForm(java.awt.event.WindowEvent evt) {
070            ResetMenu.this.setVisible(false);
071        }
072    
073        /** Add Listeners to each of the bottons in the reset menu. Generally these
074         * buttons control objects in {@link DotFrame} and so the listeners are
075         * generated there and added via this method.
076         * @param lList The listener for the line deletion button
077         * @param gList The listener for the gravity deletion button
078         * @param pList The listener for the button to stop the ball and center it
079         * @param aList The listener for the all of the above button
080         */    
081        public void addListeners(ActionListener lList, ActionListener gList,
082                                 ActionListener pList, ActionListener aList) {
083            lines.addActionListener(lList);
084            grav.addActionListener(gList);
085            pos.addActionListener(pList);
086            all.addActionListener(aList);
087        }
088    
089    }
090    
091    /*
092     * $Log: ResetMenu.java,v $
093     * Revision 1.4  2003/01/17 18:40:22  gus
094     * Adjust the grid layout to accomodate the fact that we nolonger have a
095     * close this window button.
096     *
097     * Revision 1.3  2003/01/17 18:34:55  gus
098     * Shrink the size of and simplify this window. Activate the close widow icon, and
099     * add javadocs too
100     *
101     * Revision 1.2  2003/01/15 17:36:10  gus
102     * adding log keywords to files that don't have them
103     *
104     */