| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 656 人关注过本帖
标题:一个有错误的程序
取消只看楼主 加入收藏
lyccs999
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-4-23
收藏
 问题点数:0 回复次数:1 
一个有错误的程序

我编译了有两处错误 但是我不知道怎么改哦~这个程序是实现用键盘的上下左右控制button的移动
import java.awt.event.*;import java.applet.*;
import java.awt.*;
public class 1
{ button b_go=new button("go"),
int b_x=0,b_y=0;
public void init()
{ b_go.addkeylistener(this);
}
public void keypressed(keyevent e)
{ if(e.getkeycode()==leyevent.VK_UP)
{ rectangle rect=new rectangle(b_x,b_y,20,20);
b_y=b_y-2;b_go.setlocation(b_x,b_y);
}
if(e.getkeycode()==leyevent.VK_DOWN)
{ rectangle rect=new rectangle(b_x,b_y,20,20);
b_y=b_y+2;b_go.setlocation(b_x,b_y);
}
if(e.getkeycode()==leyevent.VK_RIGHT)
{ rectangle rect=new rectangle(b_x,b_y,20,20);
b_x=b_x+2;b_go.setlocation(b_x,b_y);
}
if(e.getkeycode()==leyevent.VK_LETT)
{ rectangle rect=new rectangle(b_x,b_y,20,20);
b_x=b_x-2;b_go.setlocation(b_x,b_y);
}
}
public void keyreleased(keyevent e){}
public vold keytyped(keyevent e){}
public voide actionperformed(actionevent e)
{ b_go.setbounds(22,45,20,20);
b_x=b_go.getbounds().x;b_y=b_go.getbounds().y;
b_go.requestfocus() ;
}
}

搜索更多相关主题的帖子: void 键盘 public button import 
2006-04-26 16:17
lyccs999
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2006-4-23
收藏
得分:0 
import java.awt.event.*;import java.applet.*;
import java.awt.*;
public class 1
{ Button b_go=new Button("go"),
int b_x=0,b_y=0;
public void init()
{ b_go.addkeylistener(this);
}
public void keyPressed(KeyEvent e)
{ if(e.getKeycode()==KeyEvent.VK_UP)
{ Rectangle rect=new Rectangle(b_x,b_y,20,20);
b_y=b_y-2;b_go.setLocation(b_x,b_y);
}
if(e.getKeycode()==KeyEvent.VK_DOWN)
{ Rectangle rect=new Rectangle(b_x,b_y,20,20);
b_y=b_y+2;b_go.setLocation(b_x,b_y);
}
if(e.getKeycode()==KeyEvent.VK_RIGHT)
{ Rectangle rect=new Rectangle(b_x,b_y,20,20);
b_x=b_x+2;b_go.setLocation(b_x,b_y);
}
if(e.getKeycode()==KeyEvent.VK_LETT)
{ Rectangle rect=new Rectangle(b_x,b_y,20,20);
b_x=b_x-2;b_go.setLocation(b_x,b_y);
}
}
public void keyReleased(KeyEvent e){}
public vold keyTyped(KeyEvent e){}
public voide actionPerFormed(ActionEvent e)
{ b_go.setBounds(22,45,20,20);
b_x=b_go.getBounds().x;b_y=b_go.getBounds().y;
b_go.requestFocus() ;
}
}
改过来了哦~还有什么地方哦?
2006-04-26 16:50
快速回复:一个有错误的程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.046406 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved