11 package com.google.scrollview.ui;
17 import java.awt.Component;
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ActionListener;
20 import java.util.HashMap;
22 import javax.swing.JMenu;
23 import javax.swing.JPopupMenu;
36 private JPopupMenu root;
38 private HashMap<String, SVAbstractMenuItem> items;
48 root =
new JPopupMenu();
50 items =
new HashMap<String, SVAbstractMenuItem>();
64 public void add(String parent, String
name,
int id) {
66 if (items.get(name) != null) {
return; }
68 if (parent.equals(
"")) {
69 JMenu jli =
new JMenu(name);
70 SVAbstractMenuItem mli =
new SVSubMenuItem(name, jli);
76 SVAbstractMenuItem jmi = items.get(parent);
77 JMenu jli =
new JMenu(name);
78 SVAbstractMenuItem mli =
new SVSubMenuItem(name, jli);
84 SVAbstractMenuItem jmi = items.get(parent);
86 System.out.println(
"ERROR: Unknown parent " + parent);
89 SVAbstractMenuItem mli =
new SVEmptyMenuItem(
id, name);
90 mli.mi.addActionListener(
this);
111 public void add(String parent, String
name,
int id, String value, String desc) {
112 SVAbstractMenuItem jmi = items.get(parent);
113 SVMenuItem mli =
new SVMenuItem(
id, name, value, desc);
114 mli.mi.addActionListener(
this);
115 items.put(name, mli);
132 SVAbstractMenuItem svm = items.get(e.getActionCommand());
141 public void show(Component Invoker,
int x,
int y) {
142 root.show(Invoker, x, y);
void add(String parent, String name, int id)
void actionPerformed(ActionEvent e)
void show(Component Invoker, int x, int y)
void add(String parent, String name, int id, String value, String desc)