Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: J2ME
dear all
 
I developed a J2ME application in Netbeans. It was running well last day. but now whenever i run the project It redirects the page on j2me Default form as displaying Hello! Hello Word screen rather then to display my activeform
 
what would be the problem in it?
 
(as application it should display the mainform but it displaying now the default string used by j2me as hello hello world.
 
package allflexisms;
 

 
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Vector;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
//import javax.wireless.messaging.MessageConnection;
//import javax.wireless.messaging.MessageListener;
//import javax.wireless.messaging.TextMessage;
 

/**
* @author Vikas Kaushik
*/
public class HelloMIDlet extends MIDlet implements CommandListener {

private boolean midletPaused = false;
private Display display = Display.getDisplay(this);
Form mainForm = new Form("Welecome to AllFlexi.in");
Form ActiveForm;

private Command GetSMS = new Command("Login", Command.OK, 1);
private Command backButton;
private Command exitButton = new Command("Exit Application", Command.OK, 2);

private static final String RECORD_ADDED = "N";
private static final String ORDER_SHIPPED = "N";
//UI Text Fields
TextField UNUM = new TextField("Number:", "", 12, TextField.ANY);
TextField USMS = new TextField("SMS", "", 20, TextField.PASSWORD);

StringItem ErrorVal = new StringItem("", "");

private Command exitCommand;
private Form form;
private StringItem stringItem;
private Ticker ticker;
 
/**
* The HelloMIDlet constructor.
*/
public HelloMIDlet()
{
mainForm.append(UNUM);
mainForm.append(USMS);
mainForm.addCommand(GetSMS);
mainForm.setCommandListener(this);
display.setCurrent(mainForm);
}
 
private void initialize() {
}
 
/**
*
*/
public void startMIDlet() {
switchDisplayable(null, getForm());
}
 

public void resumeMIDlet() {
}
 
public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
Display display = getDisplay();
if (alert == null) {
display.setCurrent(nextDisplayable);
} else {
display.setCurrent(alert, nextDisplayable);
}
}
 
public void commandAction(Command command, Displayable displayable) {
if (command==GetSMS)
{
}
if (displayable == form)
{
if (command == exitCommand)
{
exitMIDlet();
}
}
}
 
public Command getExitCommand() {
if (exitCommand == null) {
exitCommand = new Command("Exit", Command.EXIT, 0);
}
return exitCommand;
}
 
public Form getForm() {
if (form == null)
{
form = new Form("Welcome", new Item[]{getStringItem()});
form.setTicker(getTicker());
form.addCommand(getExitCommand());
form.setCommandListener(this);
}
return form;
}
 
public StringItem getStringItem() {
if (stringItem == null) {
stringItem = new StringItem("Hello", "Hello, World!");
}
return stringItem;
}
 
public Ticker getTicker() {
if (ticker == null) {
ticker = new Ticker("");
}
return ticker;
}
 
public Display getDisplay() {
return Display.getDisplay(this);
}
public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}
public void startApp() {
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
startMIDlet();
}
midletPaused = false;
}
public void pauseApp() {
midletPaused = true;
}
 
public void destroyApp(boolean unconditional) { }
 
}
Posted 28-Nov-12 21:10pm
Edited 29-Nov-12 5:20am
v2
Comments
Richard MacCutchan at 29-Nov-12 6:20am
   
How could we answer that without some more information about what your program is doing? Show the code that fails and explain what you think it should do.
onlineQry at 29-Nov-12 9:43am
   
BELOW IS OUR CODE SIMPLY IT SHOULD DISPLAY MAINFORM BUT IT DISPLAY DEFAULT FOR SHOW HELLO! HELLO WORLD
 
package allflexisms;
 

 
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.util.Vector;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
//import javax.wireless.messaging.MessageConnection;
//import javax.wireless.messaging.MessageListener;
//import javax.wireless.messaging.TextMessage;
 

/**
* @author Vikas Kaushik
*/
public class HelloMIDlet extends MIDlet implements CommandListener {

private boolean midletPaused = false;
private Display display = Display.getDisplay(this);
Form mainForm = new Form("Welecome to AllFlexi.in");
Form ActiveForm;
//Command Button
private Command GetSMS = new Command("Login", Command.OK, 1);
private Command backButton;
private Command exitButton =new Command("Exit Application", Command.OK, 2);

private static final String RECORD_ADDED = "N";
private static final String ORDER_SHIPPED = "N";
//UI Text Fields
TextField UNUM = new TextField("Number:", "", 12, TextField.ANY);
TextField USMS = new TextField("SMS", "", 20, TextField.PASSWORD);

StringItem ErrorVal = new StringItem("", "");

////GEN-BEGIN:|fields|0|
private Command exitCommand;
private Form form;
private StringItem stringItem;
private Ticker ticker;
//
//GEN-END:|fields|0|
 
/**
* The HelloMIDlet constructor.
*/
public HelloMIDlet()
{
mainForm.append(UNUM);
mainForm.append(USMS);
mainForm.addCommand(GetSMS);
mainForm.setCommandListener(this);
display.setCurrent(mainForm);
}
 
////GEN-BEGIN:|methods|0|
//
//GEN-END:|methods|0|
////GEN-BEGIN:|0-initialize|0|0-preInitialize
/**
* Initializes the application. It is called only once when the MIDlet is
* started. The method is called before the
* startMIDlet method.
*/
private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
// write pre-initialize user code here
//GEN-LINE:|0-initialize|1|0-postInitialize
// write post-initialize user code here
}//GEN-BEGIN:|0-initialize|2|
//
//GEN-END:|0-initialize|2|
 
////GEN-BEGIN:|3-startMIDlet|0|3-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Started point.
*/
public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
// write pre-action user code here
switchDisplayable(null, getForm());//GEN-LINE:|3-startMIDlet|1|3-postAction
// write post-action user code here
}//GEN-BEGIN:|3-startMIDlet|2|
//
//GEN-END:|3-startMIDlet|2|
 
////GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
/**
* Performs an action assigned to the Mobile Device - MIDlet Resumed point.
*/
public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
// write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
// write post-action user code here
}//GEN-BEGIN:|4-resumeMIDlet|2|
//
//GEN-END:|4-resumeMIDlet|2|
 
////GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
/**
* Switches a current displayable in a display. The
* display instance is taken from
* getDisplay method. This method is used by all actions in the
* design for switching displayable.
*
* @param alert the Alert which is temporarily set to the display;
* if null
Richard MacCutchan at 29-Nov-12 10:01am
   
Please use the "Improve Question" link and put this (correctly formatted) into your question, so everyone can read it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100