bluegammon.gui
Class SoftButtonControl

java.lang.Object
  extended bybluegammon.gui.SoftButtonControl

public class SoftButtonControl
extends java.lang.Object

A custom item for softbuttons. Has functionality for setting one Command per softbutton. This also binds the backbutton if any of the command's type is Command.BACK.

Author:
Peter Andersson

Constructor Summary
SoftButtonControl()
           
 
Method Summary
 void enable(javax.microedition.lcdui.Command c, boolean enable)
          Enables/disables a command.
 javax.microedition.lcdui.CommandListener getCommandListener()
          Returns the command listener.
 javax.microedition.lcdui.Command getLeftCommand()
          Returns the command assigned to left softbutton.
 javax.microedition.lcdui.Command getRightCommand()
          Returns the command assigned to right softbutton.
 void init(javax.microedition.lcdui.Displayable d, javax.microedition.lcdui.Font font, javax.microedition.lcdui.Command leftCommand, javax.microedition.lcdui.Command rightCommand)
          Initializes this softbutton control.
 void keyPressed(int keyCode)
          Call this from the displayable when a key is pressed to activate this control.
 void paint(javax.microedition.lcdui.Graphics g)
          Call this from the displayable a repaint is necessary to draw this control
 void setCommandListener(javax.microedition.lcdui.CommandListener listener)
          Sets the commandlistener that will be reported upon softkey presses.
 void setLeftCommand(javax.microedition.lcdui.Command c)
          Sets the left softbutton command.
 void setRightCommand(javax.microedition.lcdui.Command c)
          Sets the right softbutton command.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SoftButtonControl

public SoftButtonControl()
Method Detail

init

public void init(javax.microedition.lcdui.Displayable d,
                 javax.microedition.lcdui.Font font,
                 javax.microedition.lcdui.Command leftCommand,
                 javax.microedition.lcdui.Command rightCommand)
Initializes this softbutton control.

Parameters:
d - The displayable that this control draw on.
font - The font used for rendering softbuttons.
leftCommand - The left softbutton command or null.
rightCommand - The right softbutton command or null.

getCommandListener

public javax.microedition.lcdui.CommandListener getCommandListener()
Returns the command listener.

Returns:
The command listener.

setCommandListener

public void setCommandListener(javax.microedition.lcdui.CommandListener listener)
Sets the commandlistener that will be reported upon softkey presses.

Parameters:
listener - The listener.

getLeftCommand

public javax.microedition.lcdui.Command getLeftCommand()
Returns the command assigned to left softbutton.

Returns:
The left comamand.

setLeftCommand

public void setLeftCommand(javax.microedition.lcdui.Command c)
Sets the left softbutton command.

Parameters:
c - The command.

getRightCommand

public javax.microedition.lcdui.Command getRightCommand()
Returns the command assigned to right softbutton.

Returns:
The right comamand.

setRightCommand

public void setRightCommand(javax.microedition.lcdui.Command c)
Sets the right softbutton command.

Parameters:
c - The command.

enable

public void enable(javax.microedition.lcdui.Command c,
                   boolean enable)
Enables/disables a command.

Parameters:
c - The command.
enable - True for enable, false for disable.

keyPressed

public void keyPressed(int keyCode)
Call this from the displayable when a key is pressed to activate this control.

Parameters:
keyCode - The keycode reported in Displayable's keyPressed method.

paint

public void paint(javax.microedition.lcdui.Graphics g)
Call this from the displayable a repaint is necessary to draw this control

Parameters:
g - The graphics context reported in Displayable's paint method.