模糊编译器错误 "cannot find symbol",但未指定哪个符号
Vague Compiler error "cannot find symbol", but doesn't specify which symbol
*这个问题不是 "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);
}
}
这是家庭作业,我只是寻求帮助解决一个错误及其解决方案
main
是 static
并且对实例方法不可见。变化
addCompstoGui(gui.getContentPane());
到
gui.addCompsToGui(gui.getContentPane());
addCompstoGui(gui.getContentPane()); // java naming convention Error
gui.addCompsToGui(gui.getContentPane()); //Successfully run becoz
//method name should be addCompsToGui and instance should associate with ths
*这个问题不是 "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);
}
}
这是家庭作业,我只是寻求帮助解决一个错误及其解决方案
main
是 static
并且对实例方法不可见。变化
addCompstoGui(gui.getContentPane());
到
gui.addCompsToGui(gui.getContentPane());
addCompstoGui(gui.getContentPane()); // java naming convention Error
gui.addCompsToGui(gui.getContentPane()); //Successfully run becoz
//method name should be addCompsToGui and instance should associate with ths