
sir,
i want to show system time on a textfield in awt(java). woulk you send me an example of time which can show time in standard format like H:M:S
pls help me sir

Display time in JTextField
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
public class ShowTime extends JFrame{
ShowTime(){
JTextField text=new JTextField(10);
add(text);
text.setEditable(false);
pack();
setVisible(true);
while(true){
try {
Thread.sleep(1000);
Calendar cal = new GregorianCalendar();
String hour = String.valueOf(cal.get(Calendar.HOUR));
String minute = String.valueOf(cal.get(Calendar.MINUTE));
String second = String.valueOf(cal.get(Calendar.SECOND));
text.setText(hour + ":" + minute + ":" + second);
}
catch (Exception e) {}
}
}
public static void main(String args[]){
new ShowTime();
}
}

thank you sanjeev
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.