javacompiler-errorsjframecontentpane

Vague Compiler error "cannot find symbol", but doesn't specify which symbol


*This question is not a duplicate of "non-static method cannot be referenced from a static context?", and it covers a different error message, which is "Cannot find symbol".

I'm having an issue with JCreator showing the build error error: cannot find symbol, while not specifying what symbol is found.

code:

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);
    }
}

This is homework, and I'm only looking for help with the one error and it's resolution


Solution

  • main is static and has no visibility to instance methods. Change

    addCompstoGui(gui.getContentPane());
    

    to

    gui.addCompsToGui(gui.getContentPane());