Best Blogger Tips

Monday 17 September 2012

Cool Unsynchronized Code for a digital clock in java!


java digital clock code
import java.awt.FlowLayout;
import java.awt.Font;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;


class clock extends JFrame
{
 int sec = 0;
    int min = 0;
    int hour = 0;
   
 
 public clock(){
  super("Clock");
  setVisible(true);
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  setSize(90, 80);
  setLocationRelativeTo(null);
  setLayout(new FlowLayout());
  JTextField fr = new JTextField(10);
  
  fr.setFont(new Font("Serif",Font.BOLD,19));
  fr.setEditable(false);
  add(fr);
             for(hour=1;hour<24;hour++)
             {
                 for(min=0;min<60;min++)
                 {
                     for(sec=0;sec<60;sec++)
                     {
                      
                      
                         fr.setText("          "+hour+":"+ min+":"+sec);
                         try{Thread.sleep(1000);}
                         catch(Exception e){}
                       
                     }

                 }
             }

         
  
 }
 
 
 
    public static void main(String args[])
    {
     
     new clock();   
    }
}




Kindly Bookmark this Post using your favorite Bookmarking service:
Technorati Digg This Stumble Stumble Facebook Twitter
YOUR ADSENSE CODE GOES HERE

0 comments:

Blogger Tricks And TipsComment here

 

| Bloggers Broadcast © 2010. All Rights Reserved | Back To Top |

Your Text Link Here