Solved

unable to set Timer on a jTextField

Posted on 2013-01-08
7
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 26

Expert Comment

by:ksivananth
ID: 38754340
try OuterClassName.this

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

Expert Comment

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

Author Comment

by:MILIND_JOG
ID: 38754455
Sorry I forgot to attach source file. Please find the same.

Regards
newGuest.java
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
LVL 17

Expert Comment

by:krakatoa
ID: 38754666
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
ID: 38754813
@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
ID: 38810429
Thanks CEHJ,

The issue is resolved.

Regards
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 38811250
:)
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

687 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