*这个问题不是“non-static method cannot be referenced from a static context?”的重复,它涵盖了不同的错误消息,即“Cannot find symbol”。
我在 JCreator 显示构建错误时遇到问题error: cannot find symbol
,但没有指定找到什么符号。
代码:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class FanTest extends JFrame
{
public FanTest()
{
setLayout(new GridBagLayout());
//more stuff here
}
public void addCompsToGui(Container pane)
{
pane.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
//more stuff here
}
public static void main(String[] args)
{
FanTest gui = new FanTest();
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setSize(600,600);
gui.setTitle("Test Console for Fan");
addCompstoGui(gui.getContentPane()); // error pointing to this line
gui.setVisible(true);
}
}
这是家庭作业,我只是在寻求解决一个错误的帮助