Frame color change,
September 12, 2009 at 11:18 AM
i want to change background color repeatedly using for loop inside Thread using only package AWT can it possible. Solve it :- import java .awt.*; import java .awt.event.*; import java.applet.*; public class colorchangeappletdemo extends Applet implements Runnable {Image img; Button b; Thread th;
public void init() { b=new Button("Start color Change"); add(b); setBackground(Color.RED); //button action b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg){th.start();} ; }); //buton action complete } public void run() {for(int i=0;i<50;i++) {try{th.sleep(1000);}catch(Exception e){System.out.println("aditya u r in danger");} Color c=new Color(10+i,20+i,30+i); System.out.println(c); } }; }
View All Comments
| View Tutorial