前面的大家不用怎么看,因为是完全自己写的,所以比较乱,麻烦大家稍微耐心一点帮忙看下。想实现最后的那个键盘监听的功能(按下↑按键时打印up),仍然不起作用。这是什么原因,应该如何解决?
package com.briup.main;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.HashMap;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import com.briup.exit.ExitOrRestart;
import com.briup.help.Remain;
import com.briup.help.Saveing;
import com.briup.help.Score;
import com.briup.help.Timer;
import com.briup.help.Title;
import com.briup.login.LoginMain;
import com.briup.login.StartOrExit;
import com.briup.object.AddFighter;
import com.briup.object.ControlSubmarine;
import com.briup.object.Door;
import com.briup.object.Fighter;
import com.briup.object.Shoot;
import com.briup.object.Xianshi;
public class MyFrame extends JPanel{
//导入图像
final ImageIcon zhadan=new ImageIcon(MyFrame.class.getResource("/image/炸弹图.jpg"));
final ImageIcon feiji=new ImageIcon(MyFrame.class.getResource("/image/feiji.jpg"));
final ImageIcon controlsubmarine=new ImageIcon(MyFrame.class.getResource("/image/潜艇图.jpg"));
//游戏开始以前的时候的对象
private LoginMain loginMain;
private Door door;//控制门的对象door
private Title title;//控制艺术字标题的对象
private StartOrExit soe;//控制开始或者结束的对象
//临时标记位
private Map<Integer, Fighter> map;//记录飞机对象的map
private int n=0;//记录shoot线程的数量
private int num=20;//记录炮弹的剩余数量
private int i=700;//标记数据,记录潜艇的初始位置
private int j=400;
private static boolean flag=false;
//对象的创建
private JFrame frame;
private Shoot shoot;//炮弹的对象
private AddFighter addFighter;
private Fighter[] fighter;//轰炸机的对象组
private ControlSubmarine cs;//控制的潜艇的对象
private ExitOrRestart exitOrRestart;
//上侧显示页面的控件
private Xianshi xianshi;//这是背景显示的JPanel,里面包括背景,飞机,控制潜艇,炮弹等元素。
//下侧控制页面的控件
private JPanel panelkongzhi;
private PanelSelf panelself;
private PanelBisha panelbisha;
private PanelFangxiang panelfangxiang;
private PanelHuoli panelhuoli;
private PanelScores panelscores;
//自方信息界面的控件
private JPanel panelchijiu;
private JLabel textchijiu;
private JLabel chijiu;
private JPanel paneldanyao;
private JLabel textdanyao;
private JLabel danyao;//显示弹药的剩余数量的JLabel
//必杀技界面的控件
private JPanel panelsaveing;
private JLabel textsaveing;
private Saveing saveing;
private JPanel panelremain;
private JLabel textremain;
private Remain remain;
//方向界面的控件
private JButton shangBtn;
private JButton xiaBtn;
private JButton zuoBtn;
private JButton youBtn;
//火力控制界面的控件
private JPanel panelshoot;
private JPanel panelsuper;