The Artima Developer Community
Sponsored Link

Java Answers Forum
Erros in Java

5 replies on 1 page. Most recent reply: Apr 22, 2002 6:35 AM by Singh M.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Budi Handoko

Posts: 4
Nickname: woodyround
Registered: Apr, 2002

Erros in Java Posted: Apr 22, 2002 5:13 AM
Reply to this message Reply
Advertisement
Hi Java ppl.
I have got some sample from the QuickTime Java. and there is one sample code. I tried to compile it using Microsoft J++, and it won't work. the sample code with error is here:


cancelButton = new Button();
cancelButton.setLabel("Cancel");
cancelButton.setBounds(293,94,60,23) ;
add(cancelButton);

cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
dispose();
}
});

i have put in this line:
import java.awt.event.*;

the error is:
error J0014: Expected ')'
error J0012: Expected ';'
fatal error J0020: Expected 'class' or 'interface'

pls tell me what should i do. thanks.

budi


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Erros in Java Posted: Apr 22, 2002 5:24 AM
Reply to this message Reply
Budi,

_ Give us more informations on, for instance, exactly the line numbering, where the error is detected !
_ Also where did you put the import statement ?
_ The request of the class of the interface definition is certainly due to a type or an error in the order the statements are made !

Thomas,


Please note the following :
  cancelButton = new Button();
  cancelButton.setLabel("Cancel");

can be re-wrtten as :
  cancelButton = new Button("Cancel");

Budi Handoko

Posts: 4
Nickname: woodyround
Registered: Apr, 2002

Re: Errors in Java Posted: Apr 22, 2002 5:41 AM
Reply to this message Reply
cancelButton.addActionListener(new ActionListener() { (line 46)
public void actionPerformed(ActionEvent event) { (line 47)
dispose(); (line 48)
} (line 49)
}); (line 50)

the errors:
(46,55) : error J0014: Expected ')'
(46,55) : error J0012: Expected ';'
(50,4) : fatal error J0020: Expected 'class' or 'interface'

i put the import at the top of the file. one more thing, i try to close the codes, and it seems that it is unable to find the java.awt.event.*
how do i make the J++ able to find it?
thanks a lot.

budi

ps: i m a beginner in java, so thanks so much for your help.

Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: Errors in Java Posted: Apr 22, 2002 6:18 AM
Reply to this message Reply
Budi
these lines look fine toome :
  cancelButton.addActionListener(
       new ActionListener() 
       { 
         public void actionPerformed ( ActionEvent event) 
         { 
           dispose(); 
         } // end of actionPerformed
       }); // end of anonymous & ActionListener


You code loos to be in an inner class.
My feeling is that you forgot to declare it as it should. Please indicate the entire code of the class (top level) !

Note that the forum is Java not M$-J++
Before replying give a look @ http://www.artima.com/forums/howtopost.html

Cheers,

Thomas,

Budi Handoko

Posts: 4
Nickname: woodyround
Registered: Apr, 2002

Re: Errors in Java Posted: Apr 22, 2002 6:30 AM
Reply to this message Reply
Hi Thomas.

I guess I know where I am wrong already. The problem is i don't have the java.awt.event.* in my harddrive. Do you have any idea where I can get it? What I have is only the java.awt.*
Do you have any address for me to download?

Thank you so much, Thomas.

Regards,

Budi

Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: Errors in Java Posted: Apr 22, 2002 6:35 AM
Reply to this message Reply
Get Sun's JDK and you will have it all.

Flat View: This topic has 5 replies on 1 page
Topic: problem in imageFilter Previous Topic   Next Topic Topic: MD5 and Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use