|
Tesseract
3.02
|
Inherits ActionListener.
Public Member Functions | |
| SVMenuBar (SVWindow scrollView) | |
| void | actionPerformed (ActionEvent e) |
| void | add (String parent, String name, int id) |
| void | add (String parent, String name, int id, boolean b) |
The SVMenuBar class provides the functionality to add a menubar to ScrollView. Each menubar item gets associated with a (client-defined) command-id, which SVMenuBar will return upon clicking it.
Definition at line 31 of file SVMenuBar.java.
| com.google.scrollview.ui.SVMenuBar.SVMenuBar | ( | SVWindow | scrollView | ) | [inline] |
Create a new SVMenuBar and place it at the top of the ScrollView window.
| scrollView | The window our menubar belongs to. |
Definition at line 44 of file SVMenuBar.java.
{
root = new JMenuBar();
svWindow = scrollView;
items = new HashMap<String, SVAbstractMenuItem>();
svWindow.setJMenuBar(root);
}
| void com.google.scrollview.ui.SVMenuBar.actionPerformed | ( | ActionEvent | e | ) | [inline] |
A click on one of the items in our menubar has occured. Forward it to the item itself to let it decide what happens.
Definition at line 56 of file SVMenuBar.java.
{
// Get the corresponding menuitem.
SVAbstractMenuItem svm = items.get(e.getActionCommand());
svm.performAction(svWindow, SVEventType.SVET_MENU);
}
| void com.google.scrollview.ui.SVMenuBar.add | ( | String | parent, |
| String | name, | ||
| int | id | ||
| ) | [inline] |
Add a new entry to the menubar.
| parent | The menu we add our new entry to (should have been defined before). If the parent is "", we will add the entry to the root (top-level) |
| name | The caption of the new entry. |
| id | The Id of the new entry. If it is -1, the entry will be treated as a menu. |
Definition at line 73 of file SVMenuBar.java.
{
// A duplicate entry - we just throw it away, since its already in.
if (items.get(name) != null) { return; }
// A new submenu at the top-level
if (parent.equals("")) {
JMenu jli = new JMenu(name);
SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
items.put(name, mli);
root.add(jli);
}
// A new sub-submenu
else if (id == -1) {
SVAbstractMenuItem jmi = items.get(parent);
JMenu jli = new JMenu(name);
SVAbstractMenuItem mli = new SVSubMenuItem(name, jli);
items.put(name, mli);
jmi.add(jli);
}
// A new child entry. Add to appropriate parent.
else {
SVAbstractMenuItem jmi = items.get(parent);
if (jmi == null) {
System.out.println("ERROR: Unknown parent " + parent);
System.exit(1);
}
SVAbstractMenuItem mli = new SVEmptyMenuItem(id, name);
mli.mi.addActionListener(this);
items.put(name, mli);
jmi.add(mli);
}
}
| void com.google.scrollview.ui.SVMenuBar.add | ( | String | parent, |
| String | name, | ||
| int | id, | ||
| boolean | b | ||
| ) | [inline] |
Add a new checkbox entry to the menubar.
| parent | The menu we add our new entry to (should have been defined before). If the parent is "", we will add the entry to the root (top-level) |
| name | The caption of the new entry. |
| id | The Id of the new entry. If it is -1, the entry will be treated as a menu. |
| b | Whether the entry is initally flagged. |
Definition at line 118 of file SVMenuBar.java.
{
SVAbstractMenuItem jmi = items.get(parent);
if (jmi == null) {
System.out.println("ERROR: Unknown parent " + parent);
System.exit(1);
}
SVAbstractMenuItem mli = new SVCheckboxMenuItem(id, name, b);
mli.mi.addActionListener(this);
items.put(name, mli);
jmi.add(mli);
}