Quantcast

Swing Timer will not work in Netbeans

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Swing Timer will not work in Netbeans

capt_nemo
I am working on creating a program on top of the netbeans platform and I am wanting to create a flashing icon in a label to draw the users attention to it. To accomplish this I have been trying to use the javax.swing.Timer to assist in this process. Which I have either A) created an ActionListener with the actionPreformed ActionEvent to pass to the Timer I create with how long to count for. Or B) I created an inner class that impliments ActionListener with the actionPerformed ActionEvent in it. And neither way works because either netbeans will flag the code with several different errors ( most listed below ) or if the code has no flags and I go and type in the name of the Timer and put the period to type start(); it will say that it doesn't exist. And also when I put the period beside the timer name I created it will show the code completion of “new”. Now I didn't write down all the errors, but the main ones are listed below, but I know it isn't anything that I am doing
 because I have even cut and pasted oracles timer example into the module I am working on and it does the same thing to it. I have all the imports needed as well. I also tried other peoples code that they say works, and again, it doesn't. And I just don't know what else to do because all the knowledge I know says it should be working, all the articles I have read says it should be working, yet netbeans says it doesn't for one reason or another.

errors I have received:
#1)  when I type t.start(); to start the timer I created Timer t = new Timer(500, ImageListener);  netbeans will flag it and says ( package timer does not exist <identifier> expected )
#2) netbeans will flag Timer t = new Timer(1000, ImageListener ); as an illegal forward reference
#3) I can not figure out how I did it or the exact message, but I also get a flags that will say there is no field and would I like it to create it and that there is no import for that class when the class is inside the module itself.

For reference these are a few of the links to the code examples I cut and pasted to test and got the same errors with as I got with my own code:

http://docs.oracle.com/javase/6/docs/api/javax/swing/Timer.html
http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
http://www.leepoint.net/notes-java/other/10time/20timer.html
http://stackoverflow.com/questions/1006611/java-swing-timer
http://java.sun.com/products/jfc/tsc/articles/timer/

And if it makes any difference, I have the newest version of netbeans and it is up to date.




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Swing Timer will not work in Netbeans

Ernie Rael
A small, few lines, source code example of the problem would help
diagnose it. Could you be importing the wrong timer? there are several...

-ernie

On 3/2/2012 10:47 AM, capt_nemo wrote:

> I am working on creating a program on top of the netbeans platform and I am wanting to create a flashing icon in a label to draw the users attention to it. To accomplish this I have been trying to use the javax.swing.Timer to assist in this process. Which I have either A) created an ActionListener with the actionPreformed ActionEvent to pass to the Timer I create with how long to count for. Or B) I created an inner class that impliments ActionListener with the actionPerformed ActionEvent in it. And neither way works because either netbeans will flag the code with several different errors ( most listed below ) or if the code has no flags and I go and type in the name of the Timer and put the period to type start(); it will say that it doesn't exist. And also when I put the period beside the timer name I created it will show the code completion of “new”. Now I didn't write down all the errors, but the main ones are listed below, but I know it isn't anything that I am doing
>   because I have even cut and pasted oracles timer example into the module I am working on and it does the same thing to it. I have all the imports needed as well. I also tried other peoples code that they say works, and again, it doesn't. And I just don't know what else to do because all the knowledge I know says it should be working, all the articles I have read says it should be working, yet netbeans says it doesn't for one reason or another.
>
> errors I have received:
> #1)  when I type t.start(); to start the timer I created Timer t = new Timer(500, ImageListener);  netbeans will flag it and says ( package timer does not exist<identifier>  expected )
> #2) netbeans will flag Timer t = new Timer(1000, ImageListener ); as an illegal forward reference
> #3) I can not figure out how I did it or the exact message, but I also get a flags that will say there is no field and would I like it to create it and that there is no import for that class when the class is inside the module itself.
>
> For reference these are a few of the links to the code examples I cut and pasted to test and got the same errors with as I got with my own code:
>
> http://docs.oracle.com/javase/6/docs/api/javax/swing/Timer.html
> http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
> http://www.leepoint.net/notes-java/other/10time/20timer.html
> http://stackoverflow.com/questions/1006611/java-swing-timer
> http://java.sun.com/products/jfc/tsc/articles/timer/
>
> And if it makes any difference, I have the newest version of netbeans and it is up to date.
>
>
>
>
>
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Swing Timer will not work in Netbeans

Carlos Hoces
I have just copied and pasted those lines about Timer declaration in my NetBeans Editor, and do not have such a problems... once I made the appropiate imports.

2012/3/2 Ernie Rael <[hidden email]>
A small, few lines, source code example of the problem would help diagnose it. Could you be importing the wrong timer? there are several...

-ernie


On 3/2/2012 10:47 AM, capt_nemo wrote:
I am working on creating a program on top of the netbeans platform and I am wanting to create a flashing icon in a label to draw the users attention to it. To accomplish this I have been trying to use the javax.swing.Timer to assist in this process. Which I have either A) created an ActionListener with the actionPreformed ActionEvent to pass to the Timer I create with how long to count for. Or B) I created an inner class that impliments ActionListener with the actionPerformed ActionEvent in it. And neither way works because either netbeans will flag the code with several different errors ( most listed below ) or if the code has no flags and I go and type in the name of the Timer and put the period to type start(); it will say that it doesn't exist. And also when I put the period beside the timer name I created it will show the code completion of “new”. Now I didn't write down all the errors, but the main ones are listed below, but I know it isn't anything that I am doing
 because I have even cut and pasted oracles timer example into the module I am working on and it does the same thing to it. I have all the imports needed as well. I also tried other peoples code that they say works, and again, it doesn't. And I just don't know what else to do because all the knowledge I know says it should be working, all the articles I have read says it should be working, yet netbeans says it doesn't for one reason or another.

errors I have received:
#1)  when I type t.start(); to start the timer I created Timer t = new Timer(500, ImageListener);  netbeans will flag it and says ( package timer does not exist<identifier>  expected )
#2) netbeans will flag Timer t = new Timer(1000, ImageListener ); as an illegal forward reference
#3) I can not figure out how I did it or the exact message, but I also get a flags that will say there is no field and would I like it to create it and that there is no import for that class when the class is inside the module itself.

For reference these are a few of the links to the code examples I cut and pasted to test and got the same errors with as I got with my own code:

http://docs.oracle.com/javase/6/docs/api/javax/swing/Timer.html
http://docs.oracle.com/javase/7/docs/api/javax/swing/Timer.html
http://www.leepoint.net/notes-java/other/10time/20timer.html
http://stackoverflow.com/questions/1006611/java-swing-timer
http://java.sun.com/products/jfc/tsc/articles/timer/

And if it makes any difference, I have the newest version of netbeans and it is up to date.










--
Carlos Hoces
Loading...