944,162 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 3571
  • Java RSS
Jun 12th, 2005
0

netbeans 4.0 HELP!

Expand Post »
i know java, ive had two classes in it but ive only written it in notepad.. lol

so here im trying to make an applet in netbeans and implement an action listener.. why do i get an error at my first line here:

Java Syntax (Toggle Plain Text)
  1. import java.awt.event.*;
  2. import java.awt.*;
  3.  
  4. public class applet1 extends java.applet.Applet implements java.awt.event.ActionListener

i.e this line:

Java Syntax (Toggle Plain Text)
  1. public class applet1 extends java.applet.Applet implements java.awt.event.ActionListener

heres the error message i recieve:
Quote ...
applet1 is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
what can i do to fix this? is netbeans doing something for me to where i dont have to write this? or do i have to use a frame?

thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Wrath is offline Offline
5 posts
since Jun 2005
Jun 12th, 2005
0

Re: netbeans 4.0 HELP!

Did you override that method? If not you need to add this method in your class;

Java Syntax (Toggle Plain Text)
  1. public void actionPerformed(ActionEvent ae)
  2. {
  3. }
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Jun 12th, 2005
0

Re: netbeans 4.0 HELP!

hmm i will add that! i was just trying to get it to build but if it wont build without that class then ill add it!

also why do i have to write this like this:

Java Syntax (Toggle Plain Text)
  1. extends java.applet.Applet


why not like this:

Java Syntax (Toggle Plain Text)
  1. extends Applet

is this something new or just something netbeans does?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Wrath is offline Offline
5 posts
since Jun 2005
Jun 12th, 2005
0

Re: netbeans 4.0 HELP!

Import java.applet.*;
and that should allow it. Since you don't have an import statement you're having to use the fully qualified name. The same goes for the actionListener. If you don't want to continously use the fully qualified name, then:
import java.awt.event.*;

By the way, if you want to just test the app and not worry about adding that method, just take off the implements.... statement.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Jun 12th, 2005
0

Re: netbeans 4.0 HELP!

thanks for the help

i decided to start from the top with a hello world. well i cant get it to open the applet, ill run it and it will just build it.. heres the code, am i doing something small wrong?

Java Syntax (Toggle Plain Text)
  1. import java.awt.event.*;
  2. import java.awt.*;
  3. import java.applet.*;
  4.  
  5. public class applet1 extends Applet
  6. {
  7. public static void main(String args[])
  8. {
  9. System.out.println("Hello World");
  10. }
  11.  
  12. public void init()
  13. {
  14.  
  15. }
  16.  
  17. // TODO overwrite start(), stop() and destroy() methods
  18. }

also im wondering if i should be using an applet.. are frames and applets the same? i just want to make an application thats readily available anywhere where you have internet access
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Wrath is offline Offline
5 posts
since Jun 2005
Jun 13th, 2005
0

Re: netbeans 4.0 HELP!

Quote originally posted by Wrath ...
thanks for the help

i decided to start from the top with a hello world. well i cant get it to open the applet, ill run it and it will just build it.. heres the code, am i doing something small wrong?

Java Syntax (Toggle Plain Text)
  1. import java.awt.event.*;
  2. import java.awt.*;
  3. import java.applet.*;
  4.  
  5. public class applet1 extends Applet
  6. {
  7. public static void main(String args[])
  8. {
  9. System.out.println("Hello World");
  10. }
  11.  
  12. public void init()
  13. {
  14.  
  15. }
  16.  
  17. // TODO overwrite start(), stop() and destroy() methods
  18. }

also im wondering if i should be using an applet.. are frames and applets the same? i just want to make an application thats readily available anywhere where you have internet access
First of all, you DON'T have a main method with an applet you use the init() method(which you have). Second, applets are funny about calls to the command line, I doubt you'll get that to work. Instead make it draw the Hello world on the applet. like this:

Java Syntax (Toggle Plain Text)
  1. import java.awt.event.*;
  2. import java.awt.*;
  3. import java.applet.*;
  4.  
  5. public class applet1 extends Applet
  6. {
  7. public void init()
  8. {
  9.  
  10. }
  11. public void paint(Graphics g)
  12. {
  13. g.drawString("Hello World",0,0);
  14. }
  15. // TODO overwrite start(), stop() and destroy() methods
  16. }

See if that works.

For your last question, I would go with an applet. You won't be able to just run a framed application anywhere like you can an applet. ALL newer browsers support java and will show up applets.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Jun 13th, 2005
0

Re: netbeans 4.0 HELP!

it will only pop up the applet if i right click the actual applet1.java icon in the projects list at the left but it wont display the hello world!.. anywhere else like in run/run main project, a pop up says "no main classes found"


thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Wrath is offline Offline
5 posts
since Jun 2005
Jun 13th, 2005
0

Re: netbeans 4.0 HELP!

oops im sorry, its late!

haha yea so i had the x and y values still at 0,0 so it wasnt showing up..

thanks again!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Wrath is offline Offline
5 posts
since Jun 2005
Jun 13th, 2005
0

Re: netbeans 4.0 HELP!

No problem. Your very welcome. If you have any other trouble just give me a holler.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: 'directed acyclic word graph'??
Next Thread in Java Forum Timeline: Java GUI problem... contents of JFrame is invisible...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC