Hashtables

  • This is just one use of a hashtable
  • Store anything you want with a name
  • Extend the Hashtable class to something that contains actions:
//MiniActions.java
import java.util.Hashtable;
import java.awt.event.ActionEvent;
import javax.swing.*;

public class MiniActions extends Hashtable {
   MiniEdit theApp;

   public MiniActions(MiniEdit theApp) {
      this.theApp = theApp;

      put("new", new NewAction(theApp));
      put("open", new OpenAction(theApp));
      put("quit", new QuitAction(theApp));
   }

   public Action getAction(String name) {
      return (Action) get(name);
   }
}

Menus and Toolbars >>