Solved

unable to set Timer on a jTextField

Posted on 2013-01-08
7
220 Views
Last Modified: 2013-01-23
Dear Experts,
I am designing a JDialog which contains few jTextFields. One of that belongs to time. I am unable to set timer against that so as to get system time on the JDialog.
 I have tried but getting some error in timer = new Timer(500,this); Compilation showing error agains the word "this" and the error is " cannot be converted to java.awt.event.ActionListener by method invocation conversion". Please find the code for reference. If I remove the word "this" by "null" the error doesn't appair but required result not getting. onlt first time I am able to see the time on jTableField but not able to get real time after words.

Please help
Regards
0
Comment
Question by:MILIND_JOG
7 Comments
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
try OuterClassName.this

where OuterClassName is the name of the class which holds the class implementation of ActionListener
0
 
LVL 35

Expert Comment

by:mccarl
Comment Utility
Please find the code for reference
Couldn't find it... can you post it?
0
 

Author Comment

by:MILIND_JOG
Comment Utility
Sorry I forgot to attach source file. Please find the same.

Regards
newGuest.java
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 16

Expert Comment

by:krakatoa
Comment Utility
Your class should really be extending JFrame not JDialog, and using JPanels with LayoutManagers to display your text fields etc.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
Comment Utility
@Override
                public void actionPerformed(ActionEvent evt) {
                actionPerformed(evt);//<< NO!
                };
        });

The above line in actionPerformed will do nothing other than cause problems by attempting to make a recursive call. Do something sensible in there instead - there's nothing otherwise wrong with the Timer
0
 

Author Closing Comment

by:MILIND_JOG
Comment Utility
Thanks CEHJ,

The issue is resolved.

Regards
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
:)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now