info.gridworld.gui
Class MenuMaker<T>

java.lang.Object
  extended by info.gridworld.gui.MenuMaker<T>

public class MenuMaker<T>
extends java.lang.Object

Makes the menus for constructing new occupants and grids, and for invoking methods on existing occupants.
This code is not tested on the AP CS A and AB exams. It contains GUI implementation details that are not intended to be understood by AP CS students.


Constructor Summary
MenuMaker(WorldFrame<T> parent, java.util.ResourceBundle resources, DisplayMap displayMap)
          Constructs a menu maker for a given world.
 
Method Summary
 void addConstructors(javax.swing.JMenu menu, java.util.Collection<java.lang.Class> classes)
          Adds menu items that call all public constructors of a collection of classes to a menu
 javax.swing.JPopupMenu makeConstructorMenu(java.util.Collection<java.lang.Class> classes, Location loc)
          Makes a menu that displays all public constructors of a collection of classes.
 javax.swing.JPopupMenu makeMethodMenu(T occupant, Location loc)
          Makes a menu that displays all public methods of an object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuMaker

public MenuMaker(WorldFrame<T> parent,
                 java.util.ResourceBundle resources,
                 DisplayMap displayMap)
Constructs a menu maker for a given world.

Parameters:
parent - the frame in which the world is displayed
resources - the resource bundle
displayMap - the display map
Method Detail

makeMethodMenu

public javax.swing.JPopupMenu makeMethodMenu(T occupant,
                                             Location loc)
Makes a menu that displays all public methods of an object

Parameters:
occupant - the object whose methods should be displayed
loc - the location of the occupant
Returns:
the menu to pop up

makeConstructorMenu

public javax.swing.JPopupMenu makeConstructorMenu(java.util.Collection<java.lang.Class> classes,
                                                  Location loc)
Makes a menu that displays all public constructors of a collection of classes.

Parameters:
classes - the classes whose constructors should be displayed
loc - the location of the occupant to be constructed
Returns:
the menu to pop up

addConstructors

public void addConstructors(javax.swing.JMenu menu,
                            java.util.Collection<java.lang.Class> classes)
Adds menu items that call all public constructors of a collection of classes to a menu

Parameters:
menu - the menu to which the items should be added
classes - the collection of classes