adding

2 posts / 0 new
Last post
onestep
onestep's picture
Offline
Joined: 26 Jun 2010
Posts:
adding

this program works well with Sun emulator but not with a Nokia mobile.Is it possible to translate J2ME to Symbian with
MoSync or how should I do to get it to work with Nokia.

import javax.microedition.midlet.*; 
import javax.microedition.lcdui.*; 


public class add extends MIDlet implements CommandListener,ItemStateListener 
{ 

private boolean midletPaused = false; 

private Command exitCommand; 
private Form form; 
private TextField tex; 


public add() { 
} 

int oldNumber =0; 


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 (displayable == form) { 
if (command == exitCommand) { 

exitMIDlet(); 

} 
} 
} 

public Command getExitCommand() { 
if (exitCommand == null) { 
// write pre-init user code here 
exitCommand = new Command("Exit", Command.EXIT, 0); 
// write post-init user code here 
} 
return exitCommand; 
} 

public Form getForm() { 
if (form == null) { 

form = new Form("", new Item[] { getTex()}); 
form.addCommand(getExitCommand()); 
form.setCommandListener(this); 
form.setItemStateListener(this); 


} 
return form; 
} 

public TextField getTex() { 
if (tex == null) { 

tex = new TextField("", null, 32, TextField.NUMERIC); 

} 
return tex; 
} 

public void itemStateChanged(Item item){ 
if (item instanceof TextField){ 
TextField text=(TextField)item; 
int newNumber=Integer.parseInt(text.getString().substring(text.getString().length()-1,text.getString().length())); 
int aNum=newNumber; 
int bNum=aNum+oldNumber; 
oldNumber=bNum; 
tex.setString(""+bNum); 
form.append(""+newNumber); 

} 
} 


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) { 
} 

} 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Alex Jonsson
alexj's picture
Offline
Mobile Conjurer
Joined: 8 Sep 2009
Posts:

Dear Onestep,

At present, the MoSync SDK relies on the c/c++ languages for input, even though we've seen an experimental Ruby port already.
So sorry, you can't write j2me source code in MoSync at the time of this writing. Feel free to browse the documentation section of
this website, and the tutorials on how to proceed.

best

Alex