Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Confusion with C/C++

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Confusion with C/C++

    import java.applet.*;
    import java.awt.*;
    import java.util.Date;
    import java.text.DateFormat;
     
    		/** An Applet to display the current time */
    public class TimeDate extends Applet implements Runnable {
     				  /** A Thread to run the timer */
       protected Thread timerThread;		   /** The date object */
       Date date = new Date();				   /** The date format */
       protected DateFormat format = DateFormat.getTimeInstance();
     
       					/* Applet Lifestyle Methods */
       public void start() {
          timerThread = new Thread(this, "Clock");
          timerThread.start();
       }
     
       public void stop() {
          if (timerThread == null)
             return;
          timerThread = null;
       }
     
      		 /** Show the time, and wait a while. */
       public void run() {
          while (timerThread != null) {
             repaint();  					 // request a redraw
             try {
                timerThread.sleep(1000);
             } catch (InterruptedException e)		{ /* do nothing*/ }
          }
       } // end of run()
     
      								 /** Display the time. */
       public void paint(Graphics g) {
            Font type = new Font("Monospaced", Font.BOLD, 30);
            g.setFont(type);
          date.setTime(System.currentTimeMillis());
          g.drawString(format.format(date), 10, 100);
     g.drawString("time", 10, 300);   
    }
    } // end of TimeDate class



    below is the HTML needed to run it.
    <html>
    <head>
    <title>time clock</title>
    </head>
    <body>
    <applet code="TimeDate.class" width="600" height="400" ></applet>    
    </body>
    </html>
    Last edited by Eric; December 23rd, 2008 at 12:41 PM.


Similar Threads

  1. [SOLVED] Prime number generator program in Java
    By big_c in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 27th, 2009, 12:08 PM
  2. Replies: 3
    Last Post: February 26th, 2009, 02:04 AM