I face a problem in my java application that, when new jFrames open by clicking jButton, litte-bit freeze and after its opening(freeze time 1-2 minutes/3 minutes). I couldn't find yet whats wrong going on. but I have some doubts of below attached code. that code for taking system time and date and show all jFrames. so this code is in all jFrames. now my question is, is this freeze happening by this code..? or may any other reasons..? if this code have any wrongs plz tell me that also... I'm using NEtbeans 8.2. thanks in advance.
code:
public AdminHome() {
initComponents();
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
Date d=new Date();
SimpleDateFormat sd=new SimpleDateFormat("yyyy - MM - dd");
String s = sd.format(d);
String s1 = d.toString();
String ar[]=s1.split(" ");
jLbl_Date.setText(s);
jLbl_Time.setText(ar[3]);
}
}
}).start();
}