Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

randomly select colors from Applet

 
jack
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I relatively new to java, what I'm trying to do is list about five colours in my Applet and pass the colours into my java code, and maybe the font.....
I want to be able to Display a digital clock which randomly selects different colours which were passed from my Applet

Thanks for any help

Zip

Clock Code:

import java.awt.*;
import java.applet.*;
import java.util.*;
import java.text.*;

public class dclock extends Applet implements Runnable{
Thread animThread = null;
int delay = 1000;

public void init(){}

public void paint (Graphics g){
// get the time
Calendar cal = Calendar.getInstance();
Date date = cal.getTime();

// format it and display it
DateFormat dateFormatter =DateFormat.getTimeInstance();

g.drawString(dateFormatter.format(date), 5, 10);

}
public void start(){

if(animThread == null){
animThread = new Thread(this,"Animation");
animThread.start();
}
}

public void stop(){animThread = null;}

public void run(){

while(animThread !=null){
try{ Thread.sleep(delay);}
catch(InterruptedException e){};
repaint();
//sec++;
}
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic