简单的GUI测试应用程序找不到类

时间:2016-12-06 08:47:31

标签: java netbeans

使用Netbeans,我编写了一个简单的GUI测试应用程序,但它没有找到项目中定义的其他类。

DrawPanel:

import java.awt.Graphics;
import javax.swing.JPanel;

public class DrawPanel extends JPanel
{
    public void paintComponent( Graphics g)
    {
        super.paintComponent(g);
        int w = getWidth();
        int h = getHeight();
        g.drawLine(0, 0, w, h);
        g.drawLine(0, h, w, 0);
    }
}

Guitest2.java

package guitest2;
import javax.swing.JFrame;
public class Guitest2 {

    public static void main(String[] args) {
        DrawPanel panel = new DrawPanel();
        JFrame app = new JFrame();
        app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE);
        app.add(panel);
        app.setSize(250, 250);
        app.setVisible(true);
    }   
}

错误是

error: cannot find symbol
    DrawPanel panel = new DrawPanel();

请看图片

enter image description here

0 个答案:

没有答案