Solved

unable to set Timer on a jTextField

Posted on 2013-01-08
7
222 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
ID: 38754340
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
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 16

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 91
oracle 11g 23 83
even odd program using while loop 3 40
Crystal Reports Licensing Questions 4 12
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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

777 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