模糊编译器错误“无法找到符号”,但没有指定
*这个问题是不是重复其符号“非静态方法不能从静态上下文中引用?”,它涵盖了不同的错误信息,这是“无法找到符号”。模糊编译器错误“无法找到符号”,但没有指定
我在与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());
其实这叫做将无法工作或者是因为该方法有一个大写的“T”在它:addCompsToGui – Ascalonian
你说得对,这不是回答之前。 http://stackoverflow.com/questions/290884/what-is-the-reason-behind-non-static-method-cannot-be-referenced-from-a-static – Tunaki
@Ascalonian哎呀。修正了T. –
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
它是否给任何行号?我们需要更多的细节 – Ascalonian
行号是218,在行后面注释(从帖子底部开始第4个)。这就是编译器给我的所有细节 – Azulflame
stackTrace请因为在这里,我们不能确定哪一行是218? –