I would venture to say your issue is in how you are assigning the new values of x, y, width and height to your rectangle object.
Assuming that your modify method is in the rectangle class your code currently looks like this (I added comments on the mistakes:
public void modify(int newX, int y, int width, int h) {
int x = newX; //you are declaring a new x here...not assigning newX to rectangle's x
this.y = y; //this is correct
width = width; //here you're just assigning the parameter width its current value
this.height = height; //here you are assigning the rectangles height value to itself
}
I would HIGHLY advise finding a naming convention and sticking with it as it would help tremendously here.
Try something like this:
public void modify(int x, int y, int w, int h) { //changed names of parameters
this.x = x; //removed the int type declaration and used this. prefix
this.y = y; //changed nothing
this.width = w; //adjusted for renamed parameter, used this. prefix
this.height = h; // adjusted for renamed parameter, again used this. prefix
}
As you can see, sticking to a convention makes the code less confusing and easier to read. This also allows you to see your mistakes more easily as they will usually stick out from your convention like a sore thumb. Don't worry it comes with practice.