This is a discussion on Templates for Input/Output in J2ME? within the J2ME forums, part of the Mobile Software Development category; Hi, J2ME newbie here. I would like to know if there are templates or sample codes for accepting user input ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Hi, J2ME newbie here. I would like to know if there are templates or sample codes for accepting user input values and displaying output values as well. I am currently working on an IP Subnetting Calculator and managed to implement it on jdk (I am knowledgeable enough in Java jdk). My program accepts input (to be used as int) and uses the said values in formulas to compute for output to be displayed. The challenge is to be able to implement it in J2ME. Any help would be greatly appreciated, thanks and more power to the community |
| Sponsored Links |
| |||
| hi dchip13, below code helps you to pass input and the value you passed is multiplied by 2(modify required calculation as you need) and get desired output ...i here developed this code using simple form...for graphical user interfaces you can develop it through canvas class..... Code:
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
public class IOTemp extends Form implements CommandListener
{
TextField txtInput;
Command cmdOutput;
/** Creates a new instance of IOTemp */
public IOTemp()
{
super("IOSample");
txtInput = new TextField("Input :", "", 10, TextField.ANY);/* passing input value */
append(txtInput);
cmdOutput = new Command("Add", Command.OK, 0);/* display required output value */
setCommandListener(this);
addCommand(cmdOutput);
}
public void commandAction(Command command, Displayable displayable)
{
try
{
int input = Integer.parseInt(txtInput.getString());
append("\nOutput :" + add(input));
}
catch (NumberFormatException e)
{
}
}
public int add(int input) // calculation method
{
return input + input;
}
} Last edited by leoraja8 : 03-24-2008 at 01:56 AM. |
| |||
| Hi this is shaggy here click on the following link for free templates. thanks |
| |||
| is really useful for me, I am glad to read it here.
__________________ business card printing |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Flash Templates | jacksan | Flash Actionscript Programming | 1 | 10-20-2008 01:24 AM |
| Free templates or coding on your own? | capture | Web Design Help | 12 | 09-26-2008 01:18 AM |
| Any sites that offer a good free templates? | montyauto | HTML, CSS and Javascript Coding Techniques | 3 | 08-20-2008 10:15 PM |
| looking free templates website | johnsweet007 | Site Management and Marketing | 1 | 08-08-2008 01:50 AM |
| free templates ? | sunder.somil | The Lounge | 3 | 10-21-2007 08:32 PM |