0

I know that "cannot find symbol" shows up when there misspelled something or the variable is not in the scope it is used or something like this. But still I cannot figure out what causes that problem in my situation. I have two classes: Driver.java and DisplayPanel.java

Driver.java code :

package csHW9;

import javax.swing.JFrame;
import csHW9.DisplayPanel;

public class Driver {

    public static void main(String[] args){
        JFrame frame = new JFrame("Dungeon Diver");
        DisplayPanel panel = new DisplayPanel();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(panel);
        frame.pack();
        frame.setVisible(true);
    }

}

DisplayPanel.java code:

package csHW9;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.*;

import javax.swing.JPanel;
public class DisplayPanel extends JPanel{   
private Dungeon dungeon;

public DisplayPanel(){
    setPreferredSize(new Dimension(600, 600));
    this.dungeon = new Dungeon();
    addKeyListener(new KListener());
    setFocusable(true); 
}

Dungeon is just another class and I'm making its instance in DisplayPanel class.

The error I get is this:

 Driver.java:12: cannot find symbol
symbol  : class DisplayPanel
location: class csHW9.Driver
        DisplayPanel panel = new DisplayPanel();

I don't understand what I'm doing wrong. Any suggestions?

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
gtboy
  • 128
  • 1
  • 3
  • 12

1 Answers1

0

You need to add import statement in Driver class at top.

Example:

import yourpackage.Driver
kosa
  • 65,990
  • 13
  • 130
  • 167