public class ThreadKotak extends Thread {
// execute application
private static Kotak shapes2JPanel;
public static void main(String args[]) {
// create frame for Shapes2JPanel
JFrame frame = new JFrame("Drawing 2D Shapes");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
shapes2JPanel = new Kotak();
frame.add(shapes2JPanel); // add shapes2JPanel to frame
frame.setBackground(Color.WHITE); // set frame background color
frame.setSize(400, 400); // set frame size
frame.setVisible(true); // display frame
ThreadKotak sh = new ThreadKotak();
sh.start();
} // end main
public void run() {
while (true) {
try {
this.sleep(500);
} catch (InterruptedException ie) {
break;
}
shapes2JPanel.repaint();
}
}
}
Tidak ada komentar:
Posting Komentar