贴主认为可行的话,请您赏分为20分
import javaxswing;
import javaawt;
import javaawtgeom;
import javaawtevent;
/
@author Hardneedl
/
final public class ColorApplet extends JApplet {
private static Color[] colors = new Color[]{ColorRED, ColorBLUE,ColorMAGENTA};
private static String[] msgs = new String[]{
"你好",
"你是鼹鼠吗?",
"你知道有个动画片叫做“鼹鼠的故事吗”"
};
private static Color currentColor = colors[0];
private static String currentMsg = msgs[0];
private ActionListener _action = new ActionListener(){
private int index = 0;
public void actionPerformed(ActionEvent e) {
index++;
if (index > colorslength -1) index = 0;
currentColor=colors[index];
currentMsg = msgs[index];
repaint();
}
};
private Timer timer = new Timer(1500,_action);
public void paint(Graphics g) {
superpaint(g);
Graphics gg = gcreate();
ggsetColor(currentColor);
if (!timerisRunning()) timerstart();
Rectangle2D rct = gggetFontMetrics()getStringBounds(currentMsg,gg);
Rectangle selfRct = thisgetBounds();
int x = (int)((selfRctwidth - rctgetWidth() )/2);
int y = (int)((selfRctheight - rctgetHeight() )/2);
ggdrawString(currentMsg,x,y);
ggdispose();
}
public void destroy() {
superdestroy();
timerstop();
_action = null;
timer = null;
colors = null;
msgs = null;
}
}
以上就是关于编写一个Applet程序,使其在窗口中以红,蓝,绿各颜色循环显示;Applet program全部的内容,包括:编写一个Applet程序,使其在窗口中以红,蓝,绿各颜色循环显示;Applet program、、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)