aspose file tools*
The moose likes Applets and the fly likes Java identifier error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Java identifier error" Watch "Java identifier error" New topic
Author

Java identifier error

Bob McDaniel
Greenhorn

Joined: Jul 07, 2011
Posts: 4
Could you please tell me what "identifier" is being referred to in this error message:


Bob-McDaniel-Computer-2:applets bobmcdaniel$ javac TptCostArea.java


The full program is:




Thanks for any help you can offer.



[Edit: put code between [code] and [/code] ubb code blocks]
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

Hmm, I tried putting your code inside code blocks, but there appears to be something else screwy going on here - maybe your code has tabs in it or something.

Anyway, the carats (^) should point to where the problem lies. In the first line here, they do work:
Bob McDaniel wrote:


The carat is pointing to where it expected to find a variable identifier. You have told it that the action method will accept two parameters, one of which is an Event, and the second of which is an Object. However it does not know what to do with those two objects - it expects to put the event in a variable, and it expects you to give it the variable name (or identifier).

To put it another way, take a look at line 84 in your pasted code above. I have copied it here (although obviously the line number is meaningless out of context):
Here you have specified that the paint method is going to take one parameter, which is a Graphics object and the identifier (name) of the variable to store it in is screen.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Bob McDaniel
Greenhorn

Joined: Jul 07, 2011
Posts: 4
I notice that the "arrowheads (^)" have moved. In the original msg the first arrow points to the comma between "Event" and "java" (Event,java), and the second points to the right parenthesis (bracket) (Object)).

Geezerbob
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

Does that mean that you understand the error now?
Bob McDaniel
Greenhorn

Joined: Jul 07, 2011
Posts: 4
Thanks, Andrew. You can view the applet working at this URL <http://publish.uwo.ca/~mcdaniel/applets/TptCostArea.html>. After solving I find that I have to collapse then expand the window to see the graph (where I use values <1 for transport rates).

You will note that the labels, e.g. "Transport Rate at A", run over the text box. While one can enter a value into the box, one has to click to the right of the text then use the delete key to erase existing values before entering new ones.

This applet was created several years ago and I don't recall that problem then. Anyway I decided to edit the java file by abbreviating the labels to "Tpt Rate at A". It was when I tried to compile the file using javac in the utility "Terminal" in Mac OS 10.6.6 that the errors at issue arose. I suspect that I'm using a newer version of java now than when I created the original file.

Perhaps this background will help in making a diagnosis.

Bob
Bob McDaniel
Greenhorn

Joined: Jul 07, 2011
Posts: 4
Andrew Monkhouse wrote:Does that mean that you understand the error now?


In principle, yes, but as you see in my previous post the applet ran with no problem in its original incarnation. But if I now have to provide a name for each of Event and Object, where would I put them?
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11525
    
100

As shown in my post above, where we talked about the paint method, in Java you provide the name of the variable immediately after the type of the variable.

This has not changed in any incarnation of Java - you always needed to name the variables.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java identifier error