hi im having this error i dont now where is the mistake can you halpe me?
this is the exception:
java.lang.NullPointerException
at shape.shape.<init>(shape.java:14)
at shape.rectangle.<init>(rectangle.java:17)
at shape.listOfSHAPES.init(listOfSHAPES.java:73)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:619)

these are part of my code were it show the error
list of shapes class:

else if(shape.charAt(0)=='R'||shape.charAt(0)=='r')
               {
                   int width=Math.abs(p2.getx()-p1.getx());
                   int hight=Math.abs(p2.getY()-p2.getY());
                   rectangle rect1= new rectangle(p1,width,hight);
                   Shapes.add(rect1);
               }

rectangle class class:

rectangle(point p,int width,int hight)
    {
        super(p);
        this.width=width;
        this.hight=hight;
    }

shape class:

shape(point p3)
{
    p.setX(p3.getx());
    p.setY(p3.getY());
}

and incase the point class:

public point(int x,int y)throws ExceptionInInitializerError
    {
        if(x<0||x>200)
        {
           throw new ExceptionInInitializerError("point  "+ x +"is not in the range");
        
        }
        else
             this.x=x;
        if(y<0||y>200)
        {
         throw new ExceptionInInitializerError("point  "+ y +"is not in the range");
        }
        else
        this.y=y;
    }
    public point(point p2)
    {
        x=p2.getx();
        y=p2.getY();
    }

thanks very much for any attempt

hmmm what line is line 14 in your original code because thats the line thats throwing the exception....

its from the shape class line 3

you may want to show us the code for the entire shape class

sure

package shape;
import java.awt.Graphics;

public abstract class shape {
private point p;
shape()
{
    p=new point();

}
shape(point p3)
{
    p.setX(p3.getx());
    p.setY(p3.getY());
}
public void setX(int x)
{
    p.setX(x);
}
public void setY(int y)
{
    p.setY(y);
}
public int getY()
{
    return p.getY();
}
public int getX()
{
    return p.getx();
}
public abstract void draw(Graphics g);
}

its realy somthing weird i got i think this program whant to make me crazy >.<

What variable has a null value? Where does that variable get assigned a value?
Add a println next to where the variable gets a value to see if that code is being executed. If there is no print out, then the code is not executed and p will not get a value and will be null.

What variable has a null value? Where does that variable get assigned a value?
Add a println next to where the variable gets a value to see if that code is being executed. If there is no print out, then the code is not executed and p will not get a value and will be null.

As NormR1 said above that would be the best error checking for both beginners and pros alike,if not give your entire source code[entire app], its hard error checking code you cant even run

if I read your code correct,
p.setX(p3.getx());

p3.getx() returns a null-value. there's your issue.
check the class where you create the instances of point and shape (and the point class itself) and check whether or not you've forgotten to set the value before you try to get it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.