Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could getDisplay() method be called in MIDlet's constructor

 
Yuan-Jia Li
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, everybody.

I'm a beginner of JavaME. Recently, I studied "Beginning J2ME platform: From Novice to Professional" this book.
There is a paragraph at page 56.

You may be tempted to call getDisplay() in a MIDlet's constructor, but according to the specification,
getDisplay() can only be called after the beginning of the MIDlet's startApp() method.
If you try to call it before startApp() is called, your MIDlet may throw an exception and terminate before starting!


Is it true?
I had tried to call getDisplay() method in MIDlet's constructor. But there is no any exception or error occure.
Could someone explain it ?

Thanks!!
 
Peter Miklosko
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is out of date information.
 
Yuan-Jia Li
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
 
Prashant Rathore
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can call the getDisplay method in constructor. Since the constructor calls the super class(MIDlet) constructor before executing the getDisplay method.
 
Yuan-Jia Li
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it. Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic