Impor Java.awt.*; Color Array Private Static Color [] Color = {Color.Black, Color.Blue, Color.cyan, Color.green, Color.ORANGE, COLOR.YLLOW, COLOR.RED, COLOR.LIGHT_GRAY}; Acak (); // Buat objek acak private static getC () {// Metode mendapatkan nilai warna acak. Koordinat int y = 50; .PrintStackTrace ();} // Dapatkan komponen grafis objek grafik grafis = getGraphics (); , y, 100, y ++); if (y> = 80) {y = 50;}}});/);// start thread} public static void main (string [] args) {init (baru sleepmethodtest (), 100, 100);} // Metode Inisialisasi Program Antarmuka public static void (bingkai jFereMe, int wid th, int tinggi) {{frame.setDefaultcloseOperation (jFrame.exit_on_close); ; Metode Java yang tidak aktif adalah Metode Sleep (). Kelas utas ini. Objek ini memanggil metode setColor () untuk mengatur warna ke grafik;