The Artima Developer Community
Sponsored Link •

Java Answers Forum
Anybody know the Answer

1 reply on 1 page. Most recent reply: Dec 9, 2004 4:04 AM by GAURI

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
jonh version

Posts: 2
Nickname: lex
Registered: Dec, 2004

Anybody know the Answer Posted: Dec 7, 2004 9:32 PM
Reply to this message Reply
Advertisement
To create a swing applet that displays the date and time in a jtextfieldwith the jlabel " Today is " when the user clicks a jbutton.


GAURI

Posts: 2
Nickname: gauri
Registered: Dec, 2004

Re: Anybody know the Answer Posted: Dec 9, 2004 4:04 AM
Reply to this message Reply
Hello Jonh,

declare these variables

private GregorianCalendar gCal = new GregorianCalendar();
private String timeFormat = "hh:mm:ss";
private SimpleDateFormat formatter = new SimpleDateFormat(timeFormat);

and on the mouseclick event of a JButton write

String timeTxt = formatter.format(gCal.getTime());
jTextField1.setText(timeTxt);
if (jTextField1 != null)
jTextField1.setText(timeTxt);

This will show current time.
Gauri

Flat View: This topic has 1 reply on 1 page
Topic: Generics ... again Previous Topic   Next Topic Topic: Help on Java Event !!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use