text: hi
  i was trying the canvas based date picker code and every time i try to run it i get an unhandled exception !
  hi
  i was trying the canvas based date picker code and every time i try to run it i get an unhandled exception !
  Try the code example at Forum Nokia wiki:
  thanks,
  ~Amitabh
  I'm using netbeans, i copied the code of the 'Java ME Canvas based calendar/date picker' and when i try to run, the emulator displays 'unhandled exception! close the application?'
  i've created two classes of type 'MIDP Canvas' and copy-pasted the provided source code
  it's my first time with JAVA ME if you can help i'd be grateful
  thanks
  Try the code as is, or cut paste your code here for debuging...
  Put some try/catch to see where this exception is coming from and why
  thanks,
  ~Amitabh
  well are you just taking about the code that im2amit is talking about?
  have you created the project and the MIDlet too in order to run the Java ME project?
  I guess the code that im2amit has given is the perfect one and it must work.
  on the bottom of this page i downloaded the source code, then i created a project in netbeans 'MIDP Application' then 2 classes of type 'MIDP Canvas', i named them 'CalendarCanvas' and 'CalendarWidget' and pasted the code as it is, netbeans reported no exception, only when i run, the emulator displays the unhandled exeption.
  if the code is working fine with you plz guide me through the steps you followed to create and run the project.
  I guess that you are not creating the class MIDlet ?
  Are you?
  No :S i just created the two classes i stated before 'MIDP Canvas', what code should i provide in the class MIDlet ?
  i'm really sry i've never worked with JAVA ME and i have this project to submit.
  thanks
  Well, you do one thing create the java file, let say FirstMIDlet as the type of MIDlet if you are using netbeans IDE. Then you will see three methods in that java file called startApp(),pauseApp(), destroyApp() are even the commandAction()..
  Then you create the object of the CalendarCanvas in the constructor of the midlet and in the startApp() just set the created object as the displayable, like this...
  import javax.microedition.midlet.*;
  import javax.microedition.lcdui.*;
  public class GIFDemo extends MIDlet {
  private boolean boolMotion=false;
  private int iX=10,iY=60;
  Display mDisplay;
  Thread th;
  public void destroyApp(boolean unconditional){}
  public void pauseApp() {}
  public void startApp() {
  mDisplay = Display.getDisplay(this);
  final MyCanvas can = new MyCanvas();
  mDisplay.setCurrent(can);
  }
  }
  I created a third class of type MIDlet and i provided the following code, but when i run i'm still getting an unhandled exception error
  import javax.microedition.midlet.*;
  import javax.microedition.lcdui.*;
  /**
  * @author Owner
  */
  public class GIFDemo extends MIDlet {
  Display mDisplay;
  public void startApp() {
  mDisplay = Display.getDisplay(this);
  final CalendarCanvas can = new CalendarCanvas(this);
  mDisplay.setCurrent(can);
  }
  public void pauseApp() {
  }
  public void destroyApp(boolean unconditional) {
  }
  }
  Hi,
  On which line the exception was occurred?
  Are you able to see something on the screen?
  try to find the line of exception..
  The emulator does not specify the line on which the error occurred it just displays 'Unhandled Exception! close application?'
  I did not add anything to the code, so i guess it should work fine :S
  thanks
  Put the system.out.println("1") after the every line in the java file.Then execute the projct, the system.out.println("1") will come before the line which is just throwing the exception and is the root cause for the same..
  On which emulator are you trying to run the project.
  the thing is that as soon as the compiler connects with the agent the emulator displays the error, i tried the System.out.println... in the constructor of the CalendarCanvas and at the beginning of the startApp() method of the MIDlet and none of them had an effect. So i think the problem lies somewhere outside the code.
  thanks