JiveJdon Community Forums
在线124人   首页   主题总表   培训咨询   精华   查搜   注册    登陆
首页 » 论坛 » 项目工程开发经验谈
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表
???en_US.forumThreadNext.name??? 下一主题
Go 总共有 0 回复 / 1
 发表新帖子   回复该主题贴
玉米

悄悄话
发表文章: 4
注册时间: 2005年10月22日 21:06
[求助]怎么才能实现让同一个画布在Applet上时隐时现?请帮忙分析我代码的错误处! 2005年10月22日 22:35 到本帖网址 加入本帖到收藏夹 发送到手机 回复该主题
标签列表


// import java.awt.*;import java.awt.event.*;//本人想实现打时现时隐的兔子的效果,现在被时现时隐
import java.applet.*;
//这步卡住了,望帮忙!谢谢!
public class Room116 extends Applet implements MouseListener
{
TextField text1;
Label label1;
Button button1;
static Image img;
int n=0;int x=50,y=50;

public void init()
{setSize(400,400);
setLayout(null);setBackground(Color.pink);
button1=new Button(
"开始");
add(button1);button1.setBounds(20,20,60,25);

label1=new Label(
"你打中的兔子为",Label.RIGHT);
add(label1);label1.setBackground(Color.yellow);
label1.setBounds(170,20,134,25);
text1=new TextField(
"0");
add(text1);text1.setBounds(304,20,76,25);
button1.addMouseListener(this);
validate();
}

public void start()
{img=getImage(getCodeBase(),
"gif002.gif");}



public void mouseClicked(MouseEvent e)
{ Mycanvas canvas1=new Mycanvas(text1);
//下面是想实现的画布时现时隐的效果,但是不行,请指教,谢谢拉!
while(n<=100)
{int x=(int)Math.random()*350;
int y=(int)Math.random()*300+23;
this.add(canvas1);
canvas1.setBounds(x,y,40,40);
try{Thread.sleep(500);}
catch(InterruptedException e)
{}
remove(canvase1);
n++;
}
//到这行截止

label1.setText(
"游戏结束!你的成绩为:");
button1.setEnabled(false);
}


public void mousePressed(MouseEvent e){}
public void mouseReleased(MouseEvent e){}
public void mouseEntered(MouseEvent e){}
public void mouseExited(MouseEvent e){}

}


class Mycanvas extends Canvas implements MouseListener
//画布的实现
{TextField textfield1=null;
int count=0;
Mycanvas(TextField text1)
{setSize(40,40);
textfield1=text1;
addMouseListener(this);
}

public void paint(Graphics g)
{g.drawImage(Room116.img,0,0,40,40,this);

}

public void mouseClicked(MouseEvent ee)
{count++;
String s=String.valueOf(count);
textfield1.setText(s);
}

public void mousePressed(MouseEvent ee){}
public void mouseReleased(MouseEvent ee){}
public void mouseEntered(MouseEvent ee){}
public void mouseExited(MouseEvent ee){}

}
这个主题有 0 回复 / 1Go
???en_US.forumThreadPrev.name??? 上一主题
  Go back to the topic 返回本主题   Go back to the topic listing返回主题列表    返回页首返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache 缓存 DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Seam Spring Struts
google yahoo 新浪ViVi 365Key网摘 天极网摘 CSDN网摘 添加到百度搜藏 POCO网摘 博采网摘
查询本论坛内 回复超过的热门帖子
     回复该主题贴
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
 

手机阅读 add to google add to yahoo
解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com
anti spam