org.netbeans.microedition.lcdui.wma
Class SMSComposer

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by org.netbeans.microedition.lcdui.wma.SMSComposer
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener

public class SMSComposer
extends javax.microedition.lcdui.Canvas
implements javax.microedition.lcdui.CommandListener

The SMSComposer provides an easy and convenient way to send SMS messages directly from JavaME application.


Field Summary
static javax.microedition.lcdui.Command SEND_COMMAND
          Command fired when SMS sent.
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
SMSComposer(javax.microedition.lcdui.Display display)
          Creates a new instance of SMSComposer for given Display object.
 
Method Summary
 void commandAction(javax.microedition.lcdui.Command c, javax.microedition.lcdui.Displayable d)
          Indicates that a command event has occurred on Displayable d.
 org.netbeans.microedition.lcdui.laf.ColorSchema getColorSchema()
          Returnd component's color schema.
 javax.microedition.lcdui.CommandListener getCommandListener()
          Returns component's command listener.
protected  void keyPressed(int keyCode)
          Called when a key is pressed.
protected  void keyReleased(int keyCode)
          Called when a key is released.
protected  void paint(javax.microedition.lcdui.Graphics graphics)
          Paints this canvas.
 void sendSMS()
          Sends the message based on given non null phone number and port number.
 void setBGColor(int color)
          Sets component's background color.
 void setCommandListener(javax.microedition.lcdui.CommandListener listener)
          Sets component's command listener.
 void setDefaulBorderStyles()
          Sets Default border styles.
 void setDefaultFonts()
          Sets Default fonts.
 void setFGColor(int color)
          Sets component's foreground color.
 void setMessage(java.lang.String message)
          Sets the message text.
 void setMessageLabel(java.lang.String messageLabel)
          Sets the message text label.
 void setPhoneNumber(java.lang.String phoneNumber)
          Sets the phone number.
 void setPhoneNumberLabel(java.lang.String phoneNumberLabel)
          Sets the phone number label.
 void setPort(int portNum)
          Sets the port number
 void setSendAutomatically(boolean sendAutomatically)
          Controlls execution of sendSMS method.
protected  void showNotify()
          The implementation calls showNotify() immediately prior to this Canvas being made visible on the display.
protected  void sizeChanged(int w, int h)
          Called when the drawable area of the Canvas has been changed.
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyRepeated, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setTicker, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEND_COMMAND

public static javax.microedition.lcdui.Command SEND_COMMAND
Command fired when SMS sent.

Constructor Detail

SMSComposer

public SMSComposer(javax.microedition.lcdui.Display display)
Creates a new instance of SMSComposer for given Display object.

Parameters:
display - A non-null display object.
Method Detail

setPhoneNumber

public void setPhoneNumber(java.lang.String phoneNumber)
Sets the phone number.

Parameters:
phoneNumber - phone number

setPhoneNumberLabel

public void setPhoneNumberLabel(java.lang.String phoneNumberLabel)
Sets the phone number label.

Parameters:
phoneNumberLabel - phone number label

setMessage

public void setMessage(java.lang.String message)
Sets the message text.

Parameters:
message - message text

setMessageLabel

public void setMessageLabel(java.lang.String messageLabel)
Sets the message text label.

Parameters:
messageLabel - message text label

setPort

public void setPort(int portNum)
Sets the port number

Parameters:
portNum - port number

setSendAutomatically

public void setSendAutomatically(boolean sendAutomatically)
Controlls execution of sendSMS method. Default value of sendAutomaticly argument is Boolean.TRUE which means that method sendSMS is invoked when command Send pressed. If sendAutomaticly is Boolean.FALSE then sendSMS method is not invoked after Send command is pressed.

Parameters:
sendAutomatically - Boolean.TRUE sendSMS method is executed, Boolean.FALSE sendSMS method is NOT executed

sendSMS

public void sendSMS()
             throws java.io.IOException
Sends the message based on given non null phone number and port number.

Throws:
java.io.IOException - if the message could not be sent or because of network failure or if the connection is not available

setDefaulBorderStyles

public void setDefaulBorderStyles()
Sets Default border styles.


setDefaultFonts

public void setDefaultFonts()
Sets Default fonts.


showNotify

protected void showNotify()
The implementation calls showNotify() immediately prior to this Canvas being made visible on the display. Canvas subclasses may override this method to perform tasks before being shown, such as setting up animations, starting timers, etc.

Overrides:
showNotify in class javax.microedition.lcdui.Canvas

sizeChanged

protected void sizeChanged(int w,
                           int h)
Called when the drawable area of the Canvas has been changed. This method has augmented semantics compared to Displayable.sizeChanged. In addition to the causes listed in Displayable.sizeChanged, a size change can occur on a Canvas because of a change between normal and full-screen modes. If the size of a Canvas changes while it is actually visible on the display, it may trigger an automatic repaint request. If this occurs, the call to size Changed will occur prior to the call to paint. If the Canvas has become smaller, the implementation may choose not to trigger a repaint request if the remaining contents of the Canvas have been preserved. Similarly, if the Canvas has become larger, the implementation may choose to trigger a repaint only for the new region. In both cases, the preserved contents must remain stationary with respect to the origin of the Canvas. If the size change is significant to the contents of the Canvas, the application must explicitly issue a repaint request for the changed areas. Note that the application's repaint request should not cause multiple repaints, since it can be coalesced with repaint requests that are already pending. If the size of a Canvas changes while it is not visible, the implementation may choose to delay calls to sizeChanged until immediately prior to the call to showNotify. In that case, there will be only one call to sizeChanged, regardless of the number of size changes. An application that is sensitive to size changes can update instance variables in its implementation of sizeChanged. These updated values will be available to the code in the showNotify, hideNotify, and paint methods.

Overrides:
sizeChanged in class javax.microedition.lcdui.Canvas
Parameters:
w - the new width in pixels of the drawable area of the Canvas
h - the new height in pixels of the drawable area of the Canvas

getColorSchema

public org.netbeans.microedition.lcdui.laf.ColorSchema getColorSchema()
Returnd component's color schema.

Returns:
colorSchema

paint

protected void paint(javax.microedition.lcdui.Graphics graphics)
Paints this canvas.

Specified by:
paint in class javax.microedition.lcdui.Canvas
Parameters:
graphics - the Graphic object to be used for rendering the Canvas

keyReleased

protected void keyReleased(int keyCode)
Called when a key is released.

Overrides:
keyReleased in class javax.microedition.lcdui.Canvas
Parameters:
keyCode - the key code of the key that was released

keyPressed

protected void keyPressed(int keyCode)
Called when a key is pressed.

Overrides:
keyPressed in class javax.microedition.lcdui.Canvas
Parameters:
keyCode - the key code of the key that was pressed

setCommandListener

public void setCommandListener(javax.microedition.lcdui.CommandListener listener)
Sets component's command listener.

Overrides:
setCommandListener in class javax.microedition.lcdui.Displayable
Parameters:
listener - CommandListener

getCommandListener

public javax.microedition.lcdui.CommandListener getCommandListener()
Returns component's command listener.

Returns:
CommandListener

setBGColor

public void setBGColor(int color)
Sets component's background color.

Parameters:
color - background color

setFGColor

public void setFGColor(int color)
Sets component's foreground color.

Parameters:
color - foreground color

commandAction

public void commandAction(javax.microedition.lcdui.Command c,
                          javax.microedition.lcdui.Displayable d)
Indicates that a command event has occurred on Displayable d.

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener
Parameters:
c - a Command object identifying the command. This is either one of the applications have been added to Displayable with addCommand(Command) or is the implicit SELECT_COMMAND of List.
d - the Displayable on which this event has occurred