This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes actionListener (will not compile) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "actionListener (will not compile)" Watch "actionListener (will not compile)" New topic
Author

actionListener (will not compile)

Cuong Tran
Greenhorn

Joined: Apr 02, 2004
Posts: 1
Hi everyone, this is my first post as I'm new here...
I can't seem to get this to compile, can someone tell why it's not compiling... I'm nearly 100% sure it's not a syntax error... please help
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ April 02, 2004: Message edited by: Dirk Schreckmann ]
Sgubudu Nhlumayo
Greenhorn

Joined: Apr 01, 2004
Posts: 2
HI
Java Classes have constructors.
These are used to initialize the object.
You have used a method ,"public void question_1()",
please change this to public Chapter7(){//initialize }don't
change the code inside the method question_1.

"We are computer professionals ,we cause accidents"
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
It will help you can give us a bit more information.
First of ally, you can preserve the indentation in your code by using [ code ] tags. There is a button below the reply message box that will add them automatically to your message. Just copy and paste the code in between the tags.
More importantly, we need the error messages you get when you compile. Please copy and paste them here. Also, make a note about which line each error refers to. Comments in the code can help with this.
I'll be more than happy to help you solve the compiler errors after you post them here.
Keep coding!
Layne


Java API Documentation
The Java Tutorial
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
You have a scope problem.
Move this line
JButton btnHello1 = new JButton ("Button 1"),btnHello2 = new JButton ("Button 2");
to immediately above this line
public void question_1(){
and it should compile OK.
 
jQuery in Action, 2nd edition
 
subject: actionListener (will not compile)