adm
Class CShellMenuItem
java.lang.Object
|
+--java.awt.MenuComponent
|
+--java.awt.MenuItem
|
+--adm.CShellMenuItem
- public class CShellMenuItem
- extends java.awt.MenuItem
- implements java.awt.event.ActionListener, java.lang.Runnable
CShellMenuItem is the subclass of awt.MenuItem. It is the invisible
beans and must be added to a CMenuButton widget. Unlike awt.MenuItem,
the action event is already built into this widget. The user does not
need to implement the ActionListener.
CShellMenuItem is used to launch any non-java program. The name of this
program must be set through setShellCommand (String cmd) method. When
this menu item is selected, the built-in action is to disable this
menuItem and start a new thread to execute the program. This thread will
fork a process and wait until the program exits. It then re-enables the
menu item.
The default label for CShellMenuItem is String "[!]" . If user set the
label, the "[!] "+label will be the real label to distinguish them
from awt.MenuItem.
- Since:
- adm0.3
- See Also:
- Serialized Form
Method Summary |
void |
actionPerformed(java.awt.event.ActionEvent evt)
|
java.lang.String |
getLabel()
Return the label string (not include "[!] "). |
java.lang.String |
getShellCommand()
Return the command String. |
void |
run()
execute and wait for the command. |
void |
setLabel(java.lang.String label)
Set the label string. |
void |
setShellCommand(java.lang.String cmd)
Set up the command string. |
void |
start()
Disable the menuItem and start a new thread |
Methods inherited from class java.awt.MenuItem |
addActionListener,
addNotify,
deleteShortcut,
disable,
enable,
enable,
getActionCommand,
getShortcut,
isEnabled,
paramString,
removeActionListener,
setActionCommand,
setEnabled,
setShortcut |
Methods inherited from class java.awt.MenuComponent |
dispatchEvent,
getFont,
getName,
getParent,
getPeer,
postEvent,
removeNotify,
setFont,
setName,
toString |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
CShellMenuItem
public CShellMenuItem()
- Null constructor.
CShellMenuItem
public CShellMenuItem(java.lang.String label)
- Constructor with label parameter
- Parameters:
label
- label string
setLabel
public void setLabel(java.lang.String label)
- Set the label string. The real label will be "[!] "+label.
- Overrides:
- setLabel in class java.awt.MenuItem
- Parameters:
label
- the label String
getLabel
public java.lang.String getLabel()
- Return the label string (not include "[!] ").
- Overrides:
- getLabel in class java.awt.MenuItem
setShellCommand
public void setShellCommand(java.lang.String cmd)
- Set up the command string.
The user must call this method.
- Parameters:
cmd
- the command name need launched
getShellCommand
public java.lang.String getShellCommand()
- Return the command String.
start
public void start()
- Disable the menuItem and start a new thread
run
public void run()
- execute and wait for the command. Print the exit code and
enable the menuItem after the command exit.
- Specified by:
- run in interface java.lang.Runnable
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent evt)
- Specified by:
- actionPerformed in interface java.awt.event.ActionListener