Cet article présente l'horloge de simulation dynamique à l'aide de JFRE, dessine des horloges dans le panneau et extrait le système au moment actuel.
Implémenter le code comme suit
Importation javax.swing.; Hour Minute; Priva ;} Public int getSecond () {return second;} // dessiner la protection de l'horloge Void PaintComponent (graphiques g) {super. GetHeight ()) * 0,8 * 0,5); int xCenter = GetWidth () / 2; int yCenter = Getheight () / 2; -Clockradius, 2 * Clockradius, 2 * Clockradius); G.Drawstring ("3", XCenter + Clockradius -10, yCenter + 3); * 0. 8); Deuxièmement * (2 * MATH.PI / 60)); G.SetColor (Color.Red); 0,65); int xmin ute = (int) (xCenter + mlenth * math.sin (minute * (2 * math.pi / 60); int yMinute = (int) (xCenter -Mlenth * Math.cos (minute * ( 2 * MATH.PI / 60)); G.setColor (Color.Blue); int xhour = (int) (int) (xCenter + Hlength * Math.Sin Minute / 60.0) * (2 * Math.pi / 12)); Xhour, yhour); GetMinute ()) + ": + s.format (getSecond)), xcenter -22, yCenter -clockRadius -15);} public void setCurrentTime () {Calendar Calendar = new GregorianCalendar (); this.hour = calendar.get (get (new Calen dar.hour_of_dy); Stume JFrame Fra ME = nouveau JFRAME (DiaPlayClock "); True) {stillage horloge = new stillglock (); {E.PrintStackTrace ();} Corloge.Carte d'effet:
Ce qui précède est tout le contenu de cet article.