• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

easy fundamental oop problem

 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I get this compiling error when i try to compile my basic MIDLET. "cannot resolve symbol". And compiler refers to this line "d.setCurrent(infoAlert);". So my question, why dose it not know what d (my Display) is? Allt want to do is to display my alert when c == alertCommand. Here my Hello-World-Code

Would appreciate fast answer, thanks!
[ February 18, 2004: Message edited by: Sebastian Green ]
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
looking through the first part up to your constructor, I see you instantiate a new infoAlert object, but I do not see any reference to it before then. Try adding the line:
private Alert infoAlert;
where you declare your other global members
[ February 18, 2004: Message edited by: Jason Fox ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you certain that d is the unresolved symbol? As the previous person noted, I suspect that infoAlert is actually the problem child here. The error message always indicates which variable name it doesn't recognize. If you are using Sun's implementation of the JDK, I believe it also displays a caret (^) under the line of code it refers to. This points to the position in the line of code where it encountered the error. In this case it should be next to the name that it doesn't recognize. Also, the error message itself should indicate the name of the "unresolved symbol."
[ February 18, 2004: Message edited by: Layne Lund ]
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry I missed that part, I didnt post the whole code, just the important part. But anyway. I have a private Alert infoAlert; where I declare the others. But it still dosent work, Thanks anyway
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are right Layne, it shows a ^ on the setCurrent(). Thats odd, dont know how to solve it though. Any ideas? Here is the rest of the error message: symbol : method setCurrent (javax.microedition.lcdui.Alert)
location: class javax.microedition.lcdui.Displayable
[ February 18, 2004: Message edited by: Sebastian Green ]
 
Jason Fox
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I took a closer look and I think I figured it out. In your commandAction method, you are calling d.setCurrent, in order to reference your Display object. However, in this context, 'd' is referring to the Displayable object passed to the commandAction method, not your display. I simply changed your commandAction method to:

And it compiled and ran under sun's WTK2.1. I hope this helps,
Jason Fox
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to download the MIDP documentation to investigate your problem. Unfortunately, I'm not on my own computer and I couldn't find an on-line version of the API docs...
I'll get back with you as soon as I check out the API.
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks that made my day now I have to really try to understand your solution. Thanks once again.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I strongly suggest you download the API docs for yourself and learn how to navigate them. According to the API docs for Display, it provides two versions of setCurrent():
void setCurrent(Alert alert, Displayable nextDisplayable)

and
void setCurrent(Displayable nextDisplayable).
The compiler is complaining because you are trying to one that would look like
void setCurrent(Alert alert),
but this doesn't exist. If you look closer at the error message, it will tell you this is the problem. (For future reference, you should copy and paste the exact error message here so we can more easily diagnose your problem. You should also copy and paste your program, rather than typing it in, to avoid other problems in communicating your problem.)

Now that I've described the problem, the solution is to make sure you use an appropriate version of setCurrent(). The descriptions in the API docs may help you decide how to do this:
void setCurrent(Alert alert, Displayable nextDisplayable)
Requests that this Alert be made current, and that nextDisplayable be made current after the Alert is dismissed.
void setCurrent(Displayable nextDisplayable)
Requests that a different Displayable object be made visible on the display.
I suspect the first version is the one you wish to use. Notice that you need to indicate what will be shown after the Alert is dismissed. I suspect that you want something like this:
d.setCurrent(infoAlert, tb);
It should fix your problem, and hopefully will provide the results that you expect.
HTH
Layne
 
Sebastian Green
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just want to post a big Thanks for everyone who has been involved in my problem. Thanks for giving me your attention so fast.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic