Results 1 to 1 of 1
- 10-13-2010, 06:58 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 1
- Rep Power
- 0
Problem with simple code in Java ME SDK 3.0
Hello. First of all, I'm not an experienced Java programmer, I've only studied it for one semester one year ago.
This year I received a project called "Secure SMS messaging using J2ME". Because I'm not familiar with the J2ME (ME SDK 3.0, the version that I have) I started looking for simple tutorials to see how it works. But unfortunately I got stuck at some of the most simple tutorials out there.
I was trying some examples that are supposed to show me the date or the time on the phone screen, but I don't seem to know how to make them work.
I'm talking about the example from here:
Java Code:import java.util.*; import javax.microedition.lcdui.*; import javax.microedition.midlet.*; public class NewClass extends MIDlet implements CommandListener{ private Display disp; private Date d; Calendar c = Calendar.getInstance(); String time; private DateField currentDate; private Command start, exit; private Form form; private int index; public NewClass(){ form = new Form("Data and Time"); d = new Date(); start = new Command("start", Command.SCREEN, 1); exit = new Command("Exit", Command.EXIT, 0); currentDate = new DateField("", DateField.DATE_TIME); currentDate.setDate(d); } public void startApp(){ form.append("CURRENT TIME IS: "); index = form.append(currentDate); form.addCommand(start); form.addCommand(exit); form.setCommandListener(this); disp = Display.getDisplay(this); disp.setCurrent(form); } public void pauseApp(){} public void destroyApp(boolean uncond){} public void commandAction(Command cmd, Displayable s){ if (cmd == exit){ notifyDestroyed(); }else if (cmd == start){ d = new Date(); c.setTime(d); time = c.get(Calendar.HOUR_OF_DAY) + ":" +c.get(Calendar.MINUTE) + ":" + c.get(Calendar.SECOND); form.append("" + time); form.append("\n"); } } }
All I get after compiling it is this and then this. Can anybody explain what I'm doing wrong?
Thank you.
Similar Threads
-
please help in java code (simple)
By rahul_swe23 in forum New To JavaReplies: 4Last Post: 01-26-2009, 03:32 PM -
Please help me this is simple bit of code
By BlitzAcez in forum New To JavaReplies: 4Last Post: 11-27-2008, 05:52 AM -
A simple Java source code viewer
By Java Tip in forum SWT TipsReplies: 0Last Post: 07-11-2008, 04:34 PM -
simple problem - code wont compile
By dirtycash in forum New To JavaReplies: 1Last Post: 11-20-2007, 05:49 PM -
problem with a simple java code
By boy22 in forum New To JavaReplies: 2Last Post: 08-03-2007, 02:46 AM
Bookmarks