为什么键盘监听事件添加了没有用,求解答,下边是主要的代码 5
publicclassGameextendsThreadimplementsActionListener,KeyListener{publicstaticvoidmain...
public class Game extends Thread implements ActionListener,KeyListener{
public static void main(String args[]){
Game game = new Game();
game.start();
}
MainFace main;
Graph gra;
public Game(){
main = new MainFace();
main.inPanel.requestFocus();
main.inPanel.addKeyListener(this);
}
public class MainFace{
public JFrame frame;
public JPanel controlPanel,gamePanel,otherPanel,inPanel;
public JButton start,pause,reset;
public GridGroup group;
public JTextField score; 展开
public static void main(String args[]){
Game game = new Game();
game.start();
}
MainFace main;
Graph gra;
public Game(){
main = new MainFace();
main.inPanel.requestFocus();
main.inPanel.addKeyListener(this);
}
public class MainFace{
public JFrame frame;
public JPanel controlPanel,gamePanel,otherPanel,inPanel;
public JButton start,pause,reset;
public GridGroup group;
public JTextField score; 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询