|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
A system-independent interface for "application-smart" menu items.
An "application-smart" menu item is a menu item that will appear in in the application menu under MacOS. It will be managed as a regular menu under other OS.
The following code sample creates a "Quit" menu, registers it on the file menu and adds an action listener:
ApplicationItem about = ApplicationItemFactory.createQuitItem();
quit.register("Exit",fileMenu);
quit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
doQuit();
}
});Important you have to register with a menu, even on MacOS. The library automatically decides if the item should be added to a regular menu or to the application menu. Your code remains platform independent
The register() method is heavily overloaded to support AWT and Swing.
ApplicationItemFactory| Method Summary | |
void |
addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this menu item. |
boolean |
isAddedToMenu()
Returns true if the menu item will or has been added to application menu. |
void |
register(javax.swing.Icon icon,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(javax.swing.Icon icon,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
javax.swing.Icon icon,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
javax.swing.Icon icon,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
int mnemonic,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
int mnemonic,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
java.awt.Menu menu)
Registers the "application" menu item. |
void |
register(java.lang.String label,
java.awt.MenuShortcut shortcut,
java.awt.Menu menu)
Registers the "application" menu item. |
void |
removeActionListener(java.awt.event.ActionListener listener)
Removes the specified action listener so it no longer receives action events from this menu item. |
| Method Detail |
public void register(java.lang.String label,
java.awt.Menu menu)
throws java.lang.IllegalStateException
label - item labelmenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(java.lang.String label,
java.awt.MenuShortcut shortcut,
java.awt.Menu menu)
throws java.lang.IllegalStateException
label - item labelshortcut - menu item shortcutmenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(java.lang.String label,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
label - item labelmenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(javax.swing.Icon icon,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
icon - item iconmenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(java.lang.String label,
javax.swing.Icon icon,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
label - item labelicon - item iconmenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(java.lang.String label,
int mnemonic,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
label - item labelmnemonic - menu item mnemonic (underlined letter)menu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(java.lang.String label,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
label - item labelaccelerator - accelerator (shortcut) for the menumenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(javax.swing.Icon icon,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
icon - item iconaccelerator - accelerator (shortcut) for the menumenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(java.lang.String label,
javax.swing.Icon icon,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
label - item labelicon - item iconaccelerator - accelerator (shortcut) for the menumenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void register(java.lang.String label,
int mnemonic,
javax.swing.KeyStroke accelerator,
javax.swing.JMenu menu)
throws java.lang.IllegalStateException
label - item labelmnemonic - menu item mnemonic (underlined letter)accelerator - accelerator (shortcut) for the menumenu - menu to add the item tojava.lang.IllegalStateException - if calling register() twice or more
public void addActionListener(java.awt.event.ActionListener listener)
throws java.lang.IllegalStateException
listener - the action listener
public void removeActionListener(java.awt.event.ActionListener listener)
throws java.lang.IllegalStateException
listener - the action listenerpublic boolean isAddedToMenu()
Returns true if the menu item will or has been added to application menu. This is useful if you need to change/adapt the menu bar depending on whether the menu is in the application menu.
The following code sample adds a menu separator if the "Quit" menu will go in the menu bar.
if(quit.isAddedToMenu())
fileMenu.addSeparator();You can call this method before or after calling register()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||