|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JMenuItem
com.ccg.swing.MenuItemClass
public class MenuItemClass
A menu item that is associated with a particular class.
This class is used to create menu item's which have an associated class. This is particularily handy when building menus that allow the user to select a "implementation" of a interface, as the class associated can be dynamically loaded at run time from a property file. Use of this class follows this basic pattern:
Resources object and the setValues method to initialize text, tooltips, the
associated class, etc for the menu item.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JMenuItem |
|---|
JMenuItem.AccessibleJMenuItem |
| Nested classes/interfaces inherited from class javax.swing.AbstractButton |
|---|
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary |
|---|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface javax.swing.SwingConstants |
|---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
MenuItemClass()
Basic construction of the object. |
|
| Method Summary | |
|---|---|
Object |
createObjectInstance()
Creates a new instance of the type of object associated with the menu item. |
Class |
getObjectClass()
Get the Class which the menu item is
associated with. |
void |
setObjectClass(Class val)
Set the Class which the menu item is
associated with. |
void |
setValues(Resources r,
String tag)
Initializes object values based upon settings in a resource file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MenuItemClass()
This does the basic construction of the object only. One is
encouraged to use the setValues method to
finish setting the values for the object. If you choose to set
properties by hand, you should always set the associated class.
| Method Detail |
|---|
public void setValues(Resources r,
String tag)
This method allows one to configure the entire object through
the use of a associated Resources object. For
example, if a Resources object contained the
following properties:
nr.name=nr nr.text=New Rectangle nr.mnemonic=r nr.tooltip=Create a new rectangle nr.class=com.foo.shape.Rectangle
One could use the following code fragment to initialize a appropriate MenuItemClass object:
MenuItemClass mic = new MenuItemClass(); mic.setValues(resources,"nr");
It should be noted that ALL of the options provided by the
Resources.setMenuItemValues(com.ccg.util.TagLookup, javax.swing.JMenuItem, com.ccg.awt.ImageHolder) method are supported. The
following addition(s) have been added:
getObjectClass and the createObjectInstance methods.
r - Resources object to get properties from.tag - Tag (identity) of the properties within the resource.
IllegalArgumentException - If the "TAG.class" value was not specified, or the class
specified could not be found.public void setObjectClass(Class val)
Class which the menu item is
associated with.
val - Class to associate with menu item (must not be null).getObjectClass()
public Class getObjectClass()
throws IllegalStateException
Class which the menu item is
associated with.
IllegalStateException - If the class has never been set.setObjectClass(java.lang.Class)
public Object createObjectInstance()
throws IllegalStateException
IllegalStateException - If the class has not been set, or we could not create a new
instance of the object using the newInstance method.setObjectClass(java.lang.Class)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||