Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

  1. #1
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    please can someone tell me what is meant by this

    both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match
    Last edited by stresstedout; April 10th, 2014 at 07:33 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    There are two Timer classes. One in the javax.swing package and one in the java.util package. The compier needs to be told which one to use.
    One way is to explicitly code the package name with the class name:

    javax.swing.Timer myTimer = new javax.swing.Timer(...);

    then the compiler will know which one to use.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    In a java program.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    so i have ammened to following
      javax.swing.Timer myTimer = new javax.swing.Timer(1000, new TimerActionListener(NewClass.this));
    that but i am still getin this error

    cannot find symbol
    symbol: class TimerActionListener
    location: class NewClass

  5. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    cannot find symbol
    symbol: class TimerActionListener
    The compiler can not find the definition for the TimerActionListener class. Where is it defined?
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    this is where i have added but im not sure if this is correct
    Last edited by stresstedout; April 10th, 2014 at 07:33 PM.

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    not sure if this is correct
    The compiler will tell you. If there are no errors, then it could be correct.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    Quote Originally Posted by Norm View Post
    The compiler will tell you. If there are no errors, then it could be correct.
    this is the compiler error


    Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous ctor sym type: <any>
    at javaapplication24.NewClass.<init>(NewClass.java:24 )
    at javaapplication24.NewClass.main(NewClass.java:73)
    Java Result: 1

    line 24 is
       javax.swing.Timer myTimer = new javax.swing.Timer(1000, new TimerActionListener(NewClass.this));
    Last edited by stresstedout; April 10th, 2014 at 07:08 PM.

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    Sorry, I don't know about your IDE's error messages.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    can you tell me why this is

    cannot find symbol
    symbol: class TimerActionListener
    location: class NewClass
    Last edited by stresstedout; April 10th, 2014 at 07:32 PM.

  11. #11
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    The formatting of the code is bad enough that it is hard to see where methods begin and end.

    The missing class's definition must be out of scope for where it is referenced. Try moving its definition so it is in scope where it is referenced.
    If you don't understand my answer, don't ignore it, ask a question.

  12. #12
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    what should the method look like?

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    What method?
    If you don't understand my answer, don't ignore it, ask a question.

  14. #14
    Member
    Join Date
    Jan 2014
    Posts
    209
    My Mood
    Depressed
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: both class javax.swing.Timer in javax.swing and class java.util.Timer in java.util match

    Quote Originally Posted by Norm View Post
    What method?
    ive solved it

Similar Threads

  1. javax.swing.DefaultComboBoxModel@1a38598
    By aknessy in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 20th, 2013, 09:19 AM
  2. Does javax.swing.JToggleButton even lift ??
    By startas in forum AWT / Java Swing
    Replies: 6
    Last Post: September 8th, 2013, 11:49 AM
  3. trouble with selectAll() method of javax.swing.JTextField
    By Daddyspike in forum AWT / Java Swing
    Replies: 0
    Last Post: April 27th, 2013, 05:40 PM
  4. Swing Timer and Java Noob
    By hypnotoad in forum AWT / Java Swing
    Replies: 7
    Last Post: October 5th, 2012, 06:34 PM
  5. Replies: 6
    Last Post: January 28th, 2011, 01:13 AM