2个回答
展开全部
import java.awt.*;
import javax.swing.*;
public class ColorApplet extends JApplet implements Runnable{
String s="welcome to java applet!";
Color[] colors={Color.red,Color.green,Color.blue};
int now=0;
public void init(){
new Thread(this).start();
}
public void paint(Graphics g){
g.setColor(colors[now]);
g.drawString(s,100,100);
}
public void run(){
while(true){
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
now++;
if(now>=3)now=0;
repaint();
}
}
}
import javax.swing.*;
public class ColorApplet extends JApplet implements Runnable{
String s="welcome to java applet!";
Color[] colors={Color.red,Color.green,Color.blue};
int now=0;
public void init(){
new Thread(this).start();
}
public void paint(Graphics g){
g.setColor(colors[now]);
g.drawString(s,100,100);
}
public void run(){
while(true){
try{
Thread.sleep(1000);
}catch(InterruptedException e){}
now++;
if(now>=3)now=0;
repaint();
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询