| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 
 | import java.awt.*;
import java.util.*;
 
public class Watch extends javax.swing.JApplet{
 
	private Color butterscotch = new Color(255, 204, 102);	//definit la couleur
	private String lastTime = "";
 
public void init(){
	setBackground(Color.black);
 }
 
 public void paint(Graphics screen) {
	Graphics2D screen2D = (Graphics2D)screen;
 
	Font  type = new Font ("Monospaced", Font.BOLD, 20);	//definition de la police
 
	screen2D.setFont(type);	//application de la police à screen2D
	GregorianCalendar day = new GregorianCalendar();
	String time = day.getTime().toString();
	screen2D.setColor(Color.black);
	screen2D.drawString(lastTime, 5, 25);	//drawString : pour ecrire la chaine de caractère. Coordonnées du premier point
	screen2D.setColor(butterscotch);
	screen2D.drawString(time, 5, 25);
	try{
		Thread.sleep(1000);	//mille milliseconde
	} catch (InterruptedException e) {
	// ne rien faire
	}
	lastTime = time;
	repaint();	//methode de la librairie predefinie
	}
  } | 
Partager