Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

unable to set Timer on a jTextField

Posted on 2013-01-08
7
Medium Priority
?
228 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

618 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