Alex
Alex

Reputation: 47

Processing Java Error: The nested type (Node) cannot hide an enclosing type

I've looked up this error before, but mainly it's just people that have two class declarations.

I've been searching for hours to find some help but I can't find anything! My only other guess at what is wrong is that it's something to do with the public/private attributes. But that's just a guess!

So I'm not sure what is wrong with my code to cause this, the code is:

class Node
{
    //Variables
    private String id;
    private PVector position;
    private Float radius;
    private int headerHeight;
    private String headerText;

    //Needs var holding node links!!

    //Constructor
    public Node(String _id, int _x, int _y, Float _radius)
    {
        id = _id;
        position = new PVector(_x, _y);
        radius = _radius;

        headerHeight = 20;
        headerText = "";
    }

    //Getters and Setters
    public String getID()
    {
        return id;
    }

    public void setID(String _id)
    {
        id = _id;
    }

    public PVector getPosition()
    {
        return position;
    }

    public void setPosition(PVector _position)
    {
        position = _position;
    }

    public Float getRadius()
    {
        return radius;
    }

    public void setRadius(Float _radius)
    {
        radius = _radius;
    }

    public int getHeaderHeight()
    {
        return headerHeight;
    }

    public void setHeaderHeight(int _height)
    {
        headerHeight = _height;
    }

    public String getHeaderText()
    {
        return headerText;
    }

    public void setHeaderText(String _headerText)
    {
        headerText = _headerText;
    }

}

Upvotes: 4

Views: 9190

Answers (1)

user2468700
user2468700

Reputation: 974

Check if your tab or sketch name is the same as program's inner class name. Change the name of your tab/sketch and you'll be fine.


Rename your sketch (foo.pde) which is also the name of the tab to something other than the class name. The main sketch in processing cannot have a nested class with the same name, other sketches (other tabs) can have classes that are the same name as the tab.

Upvotes: 3

Related Questions