File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes easy fundamental oop problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "easy fundamental oop problem " Watch "easy fundamental oop problem " New topic
Author

easy fundamental oop problem

Sebastian Green
Ranch Hand

Joined: Jan 30, 2004
Posts: 136
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 ]

/ Sebastian<br />No blog, No homepage, No life?
Jason Fox
Ranch Hand

Joined: Jan 22, 2004
Posts: 114
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 ]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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 ]

Java API Documentation
The Java Tutorial
Sebastian Green
Ranch Hand

Joined: Jan 30, 2004
Posts: 136
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

Joined: Jan 30, 2004
Posts: 136
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

Joined: Jan 22, 2004
Posts: 114
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

Joined: Dec 06, 2001
Posts: 3061
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

Joined: Jan 30, 2004
Posts: 136
Thanks that made my day now I have to really try to understand your solution. Thanks once again.
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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

Joined: Jan 30, 2004
Posts: 136
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: easy fundamental oop problem