DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    1

    Need help with actionlistener - *fixed*

    I figured it out: I forgot to import javax.swing.Timer;.


    I can't figure out what I did wrong here, so I was hoping you guys can help me out:


    The complier said it couldn't find the symbol at "timer = new Timer(1000, new ActionListener()"
    Code:
    Timer timer;
    Tin tin = new Tin();
    //inside a method
    timer = new Timer(1000, new ActionListener()
       {
                public void actionPerformed(ActionEvent evt)
                {
                      if (tin.test() == true)
            		count++;
                }
       });
    Last edited by Louis_8771; 06-10-2006 at 05:34 PM.

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    I very rarely use inner classes

    ..so this is the way I would do it, I have commented out the references to Tin & count as I don't know anything about their usage.

    Code:
    import javax.swing.Timer;
    import java.awt.event.*;
    
    public class TimerTest implements ActionListener {
      Timer timer;
      //Tin tin = new Tin();
    
      public TimerTest() {
    
        timer = new Timer(1000, this);
      }
    
      public void actionPerformed(ActionEvent e) {
        //if (tin.test() == true)
        //count++;
      }
    
    }
    eschew obfuscation

Similar Threads

  1. ActionListener problem
    By digital_trex in forum Java
    Replies: 2
    Last Post: 08-31-2005, 01:30 PM
  2. Replies: 2
    Last Post: 07-24-2005, 09:42 AM
  3. Problem in actionListener
    By plan_ever in forum Java
    Replies: 1
    Last Post: 05-25-2005, 12:06 PM
  4. how to add an actionlistener?
    By skippy in forum Java
    Replies: 0
    Last Post: 11-23-2002, 06:51 PM
  5. NullPointerException when reading text file
    By Andrew McLellan in forum Java
    Replies: 3
    Last Post: 05-09-2001, 05:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links