• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

IllegalStateException

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am wondering if there is any way to debug MIDP's IllegalStateException?

I have a class subclassing Canvas (in turn Displayable). In the constructor of this class, I do:

Command c1 = new Command("CMD1", Command.SCREEN, 0);
Command c2 = new Command("CMD2", Command.SCREEN, 0);
addCommand(c1); -> IllegalStateException
addCommand(c2);

I don't believe this is a MIDP 1.0 vs. 2.0 issue. In general, any effective tips on debugging IllegalStateException?

Thanks
Victor
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Victor Ho,

You should give us more details about where this exception is happening, i mean, if you are using an emulator or real device. Anyway, are you sure you can set a priority to zero (0)? I think they start at one (1), being one the most important command.Higher priority values indicate commands of lesser importance.

Hope this helps.

Best,
 
Victor Ho
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Juarez,

The exception happens at the first line of "addCommand(c1);".

It happens to both emulator and real device (Nokia s40 and s60). As far as priority, I am pretty sure 0 is a valid value, but I tried to use 1 instead and the same problem persists.

It just seems to be the IllegalStateException is quite puzzling, ideally there should be more trace to indicate the root cause.

Victor
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Victor,

Are u writing this code in a constructor which implements the FullCanvas class of Nokia?.As far as addCommand() is concerned,normal addCommand will throw only nullpointer exception.
In the case of Nokia,In Api docs--have a look at the addcommand() in FullCanvas class...illegal exception is defined there.
Anyway you cannot add commands in FullScreen mode in Nokia

Cheers
Mandrake
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mandrake:

You've been asked at least once already to change your display name to comply with our site policies: a real (sounding) first and last name separated by a space. Please visit this page and correct this problem before posting again. Thanks.
 
Victor Ho
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mandrake,

You are exactly right. I am using the JMobilecore library and my Canvas super class ultimately extends FullCanvas of Nokia.

I have tried not doing addCommand() inside the constructor, but a separate init() method, that didn't help.

JMobilecore replied saying addCommand() for a Canvas is not allowed.

In general, is it possible to mix High-level classes such as Command in a low-level container class, such as Canvas?

Thanks
 
Prashanth Nair
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Victor,

As i mentioned earlier if you are subclassing the FullCanvas,
you will not be able to add commands in that mode.Adding Nokia Fullcanvas documentation for your reference
----------------------------------------------------
addCommand public void addCommand(javax.microedition.lcdui.Command cmd)Throws IllegalStateException.
Commands are not possible in FullCanvas.

Overrides:
addCommand in class javax.microedition.lcdui.Displayable
Throws:
java.lang.IllegalStateException - always thrown
------------------------------------------------------
Note the point that its always thrown
 
Run away! Run away! Here, take this tiny ad with you:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic