SubMenuCommandpublic class SubMenuCommand extends javax.microedition.lcdui.Command The SubMenuCommand is an extension of LCDUI's Command object.
It represents a collection of Commands which should be made
available as a type of "sub menu" under a single Command heading. |
Fields Summary |
---|
protected javax.microedition.lcdui.Command[] | subCommandsAn array holding the Commands that are part of the "submenu". | protected javax.microedition.lcdui.CommandListener | listenerThe CommandListener to notify when a sub command is selected. |
Constructors Summary |
---|
public SubMenuCommand(String label, int commandType, int priority)Creates a new command object with the given short
label,
type, and
priority.
The newly created command has no long label. This constructor is
identical to Command(label, null, commandType, priority) .
super(label, commandType, priority);
| public SubMenuCommand(String shortLabel, String longLabel, int commandType, int priority)Creates a new command object with the given
labels,
type, and
priority.
The short label is required and must not be
null . The long label is
optional and may be null if the command is to have
no long label.
super(shortLabel, longLabel, commandType, priority);
|
Methods Summary |
---|
public synchronized void | addSubCommand(javax.microedition.lcdui.Command cmd)Adds the given Command to the list of sub commands.
if (cmd == null) {
throw new IllegalArgumentException("Added command was null");
}
if (subCommands == null) {
subCommands = new Command[] { cmd };
} else {
Command[] newCommands = new Command[subCommands.length + 1];
System.arraycopy(subCommands, 0, newCommands, 0,
subCommands.length);
newCommands[subCommands.length] = cmd;
subCommands = newCommands;
newCommands = null;
}
| public synchronized void | addSubCommands(javax.microedition.lcdui.Command[] cmds)Adds the given set of Commands to the list of sub commands.
if (cmds == null) {
throw new IllegalArgumentException("Added command array was null");
}
if (subCommands == null) {
subCommands = new Command[cmds.length];
System.arraycopy(cmds, 0, subCommands, 0, cmds.length);
} else {
Command[] newCommands =
new Command[subCommands.length + cmds.length];
System.arraycopy(subCommands, 0, newCommands, 0,
subCommands.length);
System.arraycopy(cmds, 0, newCommands, subCommands.length,
cmds.length);
subCommands = newCommands;
newCommands = null;
}
| public synchronized javax.microedition.lcdui.Command[] | getSubCommands()Retrieves the set of subcommands from this SubMenuCommand.
This method will return a copy of the internal array holding
the set of sub menu Commands.
if (subCommands == null) {
return null;
}
Command[] cmdCopy = new Command[subCommands.length];
System.arraycopy(subCommands, 0, cmdCopy, 0, subCommands.length);
return cmdCopy;
| public synchronized void | notifyListener(javax.microedition.lcdui.Command c)Called to notify the CommandListener of this SubMenuCommand that
a sub command has been selected.
if (listener != null) {
listener.commandAction(c, null);
}
| public synchronized void | removeAll()Removes all commands that are currently in the list of sub commands.
subCommands = null;
| public void | setListener(javax.microedition.lcdui.CommandListener listener)Sets the CommandListener of this SubMenuCommand to notify when one
of the sub commands is selected.
this.listener = listener;
|
|