如何修复面板面板的“找不到符号”;

时间:2019-06-26 16:26:28

标签: java jpanel

我正在使用gitpod为学校项目开发游戏。问题是,由于出现“找不到符号”错误,它不会让我编译。奇怪的是,它在日食时运行良好,并且没有问题。但是,我正在使用Chromebook,目前无法下载eclipse。香港专业教育学院还尝试了另一个在线编译器,但有相同的错误。它仅在跑步类中。

package ddr;

import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class runner {
    JFrame frame;
    Panel panel; //Another error here
    final int WIDTH = 800;
    final int HEIGHT = 800;

    public runner() {

        frame = new JFrame();
        panel = new Panel(); //Error here
        frame.add(panel);   
        frame.getContentPane().setPreferredSize(new Dimension(WIDTH, HEIGHT));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setVisible(true);
        frame.addKeyListener(panel);
        setUp();
    }

    public static void main(String[] args) {
    new runner();   
    }

    public void setUp() {

    }
}

错误在这里:

   gitpod /workspace/ddr/src/ddr $ javac runner.java
   Picked up JAVA_TOOL_OPTIONS: -Xmx3543m
   runner.java:9: error: cannot find symbol
           Panel panel; 
           ^
     symbol:   class Panel
     location: class runner
   runner.java:16: error: cannot find symbol
                   panel = new Panel(); 
                               ^
     symbol:   class Panel
     location: class runner
   2 errors

0 个答案:

没有答案