import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MoveString extends Applet implements Runnable,ActionListener,TextListener{
Color darkblue = new Color(255,0,128);
Graphics offscreenG;
Image offscreenImage;
Image pictop;
Image picbuttom;
int d = 2;
int r = 140;
int angle = 0;
int x = 270;
int y = 400;
int x0 = 260;
int y0 = 200;
int font = 65;
Thread runner;
TextField textString;
String request;
String name="Wan YanKai";
public void init(){
offscreenImage = createImage(getSize().width, getSize().height);
offscreenG = offscreenImage.getGraphics();
pictop = getImage(getCodeBase(),"top.gif");
setLayout(null);
picbuttom = getImage(getCodeBase(),"buttom.gif");
setLayout(null);
textString = new TextField(name,21);
textString.addTextListener(this);
add (textString);
textString.setBounds(210,350,100,20);
Button submitButton = new Button("Submit");
submitButton.addActionListener(this);
add (submitButton);
submitButton.setBounds(330,350,50,20);
Button clearButton = new Button("Restore");
clearButton.addActionListener(this);
add (clearButton);
clearButton.setBounds(400,350,50,20);
}
public void change(){
name = textString.getText();
repaint();
}
public void textValueChanged(TextEvent t){
// change();
}
public void actionPerformed(ActionEvent e) {
request = e.getActionCommand();
if (request == "Submit")
change();
else if (request == "Restore")
{name = "Wan YanKai";
textString.setText("Wan YanKai");
repaint();
}
}
public void start(){
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void stop(){
if (runner != null) {
runner.stop();
runner = null;
}
}
public void run(){
while (true){
angle += 1;
x = (int)(r*Math.sin(2*Math.PI*angle/360))+x0;
y = (int)(r*Math.cos(2*Math.PI*angle/360))+y0;
{
if (((angle >=0)&&(angle<90))&&(angle%3==0))
font -=1;
else if (((angle >=90)&&(angle<180))&&(angle%3==0))
font -=1;
else if (((angle >=180)&&(angle<270))&&(angle%3==0))
font +=1;
else if (((angle >=270)&&(angle<360))&&(angle%3==0))
font +=1;
}
d = 2;
if (font<25) d=1;
repaint();
if (font==66) font=65;
try{
Thread.sleep(25);
}catch(InterruptedException e){}
if (angle == 360) angle=0;
}
}
public void update(Graphics g){
paint(g);
}
public void paint(Graphics g){
Font f = new Font("Arial",Font.BOLD,font);
offscreenG.setColor(Color.white);
offscreenG.fillRect(0,0,1500,500);
offscreenG.setColor(Color.black);
offscreenG.setFont(f);
offscreenG.drawImage(picbuttom,215,145,this);
offscreenG.drawString(name,x+d,y-d);
offscreenG.setColor(darkblue);
offscreenG.drawString(name,x,y);
offscreenG.drawImage(pictop,255,30,this);
g.drawImage(offscreenImage,0,0,this);
}
}
java做的世界杯程序
需积分: 50 48 浏览量
2009-05-17
17:54:24
上传
评论 2
收藏 58KB RAR 举报
zhi070202021016
- 粉丝: 6
- 资源: 58
最新资源
- MMDF1N05ER2G-VB一款SOP8封装2个N-Channel场效应MOS管
- zipkin-server-3.3.0-exec.jar
- MI9933-VB一款SOP8封装2个P-Channel场效应MOS管
- zipkin-server-2.24.4-exec.jar
- MI4953-VB一款SOP8封装2个P-Channel场效应MOS管
- 基于Akka模拟实现Spark Standalone.pdf
- MI4946-VB一款SOP8封装2个N-Channel场效应MOS管
- 毕业答辩模板(动态模板)苹果IOS星空通用论文答辩模板
- 有效cookie值获取方式汇总
- 基于python实现的英雄联盟知识图谱问答系统源码(期末大作业).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈