我尝试清理我的项目以解决这个问题并查找论坛和stackoverflow以获得解决方案但是我无法找到错误显示原因的答案。我只是将我的类导入到Actual_Game类中。错误是“导入FrameCreator无法解析”。我正在使用Eclipse作为我的IDE。
这是代码: Actual_Game.java
import FrameCreator;//<---error here
public class Actual_Game {
public static void main(String[] args) {
FrameCreator local_fc = new FrameCreator();
local_fc.CreateGameWindow();
}
}
FrameCreator.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
public class FrameCreator extends JPanel {
private static final long serialVersionUID = 1L;
/* Settings */
/* get screen size using the Toolkit class before setting it into height & width */
static Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
final String title = "Example Title";
final static int window_height = (int)(screenSize.getHeight()*.75),
window_width = (int)(screenSize.getWidth()/2);
public FrameCreator(){
setBackground(Color.BLACK);
CreateGameWindow();
}
public void CreateGameWindow(){
/* This section creates the window */
/* set the title of the screen */
JFrame archizzleFrame = new JFrame();
/* sets the size of the frame */
archizzleFrame.setSize(window_width,window_height);
/* we tell what to do when user presses "X" */
archizzleFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
/* sets visibility of the window */
archizzleFrame.setVisible(true);
}
}
它们位于相同的文件夹/包下,如下所示。
我该如何解决这个问题?