Source Code : Two Alerts

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Two Alerts

Two Alerts
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.TextBox;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;

public class TwoAlerts extends MIDlet implements CommandListener {
  private Display mDisplay;

  private TextBox mTextBox;

  private Alert mTimedAlert;

  private Alert mModalAlert;

  private Command aboutCommand, goCommand, exitCommand;

  public TwoAlerts() {
    aboutCommand = new Command("About", Command.SCREEN, 1);
    goCommand = new Command("Go", Command.SCREEN, 1);
    exitCommand = new Command("Exit", Command.EXIT, 2);

    mTextBox = new TextBox("TwoAlerts", "", 32, TextField.ANY);
    mTextBox.addCommand(aboutCommand);
    mTextBox.addCommand(goCommand);
    mTextBox.addCommand(exitCommand);
    mTextBox.setCommandListener(this);

    mTimedAlert = new Alert("Network error", "A network error occurred. Please try again.", null,
        AlertType.INFO);
    mModalAlert = new Alert("About TwoAlerts",
        "TwoAlerts is a simple MIDlet that demonstrates the use of Alerts.", null, AlertType.INFO);
    mModalAlert.setTimeout(Alert.FOREVER);
  }

  public void startApp() {
    mDisplay = Display.getDisplay(this);

    mDisplay.setCurrent(mTextBox);
  }

  public void pauseApp() {
  }

  public void destroyApp(boolean unconditional) {
  }

  public void commandAction(Command c, Displayable s) {
    if (c == aboutCommand)
      mDisplay.setCurrent(mModalAlert);
    else if (c == goCommand)
      mDisplay.setCurrent(mTimedAlert, mTextBox);
    else if (c == exitCommand)
      notifyDestroyed();
  }
}


           
       

Thank with us