บทความนี้แนะนำนาฬิกาจำลองแบบไดนามิกโดยใช้ JFRE วาดนาฬิกาในแผงควบคุมและแยกระบบในขณะนี้
ใช้รหัสดังนี้
นำเข้า Javax.swing.*; ชั่วโมง; ;} int สาธารณะ getSecond () {return second;} // วาดนาฬิกา protectd paintComponent (กราฟิก G) {super Getheight ()) * 0.8 * 0.5); -clockradius, 2 * clockradius, 2 * clockradius); G.DrawString ("3", XCENTER + CLOCKRADIUS -10, YCENTER + 3); * 0. 8); int xsecond = (int) (xcenter + slength * math.sin (วินาที * (2 * math.pi / 60))); ครั้งที่สอง * (2 * Math.pi /60))); 0.65); int xmin ute = (int) (xcenter + mlenth * math.sin (นาที * (2 * math.pi / 60)); int yminute = (int) (xcenter -mlenth * math.cos (นาที * ( 2 * math.pi / 60)); int xhour = (int) (int) (xcenter + hlength * math.sin นาที / 60.0) * (2 * math.pi / 12)); xhour, yhour); getMinute ()) + ": + s.format (getSecond)), xcenter -22, ycenter -clockradius -15);} โมฆะสาธารณะ setcurrenttime () {ปฏิทินปฏิทิน = ใหม่ gregoriancalendar (); hour.hour = calendar.get calen dar.hour_of_dy); this.minute = calendar.get (calendar.minute); jframe fra me = new jframe ("diaplayclock"); TRUE) {Stillclock clock = new Stillclock (); {E.PrintStackTrace ();} นาฬิกาแผนที่เอฟเฟกต์:
ข้างต้นเป็นเนื้อหาทั้งหมดของบทความนี้