Collision Detection With the Rectangle Class: What am I missing?

Hello all. I’ve been trying to put together a UI with basic collision detection using the Rectangle class. Within the game loop (I’m using the Display class from the lwjgl) pressing the arrow keys sets the variables dX and dY to appropriate values which are passed to an update method in the player class that moves the player around. In this build of the game everything is a simple rectangle drawn with x,y coordinates. I used the rectangle class to define the area around those rectangles using the following:


	public Rectangle getRectangle()
	{
		rectangle = new Rectangle(upperLeftCornerX, upperLeftCornerY, 
				(lowerRightCornerX - lowerLeftCornerX), (lowerRightCornerY - upperRightCornerY)); 
		return rectangle;
	}

I then created a for loop which moves through the list of objects and determines if the player has collided with them like so:


//Get the player's locations
			playerLocation = new Rectangle(player.upperLeftCornerX, player.upperLeftCornerY, 
			(player.lowerRightCornerX - player.lowerLeftCornerX), (player.lowerRightCornerY - player.upperRightCornerY)); 
			
			//Find out if the player intersects the scenery and scooch them back to a reasonable position
			for(Scenery set: scenery)
			{
				if (set.getRectangle().intersects(playerLocation))
				{
					dX = 0;
					dY = 0;
					Rectangle intersection = playerLocation.intersection(set.getRectangle());
					Point point = intersection.getLocation();
					
					if(player.upperLeftCornerX == point.x)
					{
						player.upperLeftCornerX = player.upperLeftCornerX + intersection.width;
					}
					if(player.upperLeftCornerY == point.y)
					{
						player.upperLeftCornerY = player.upperLeftCornerY + intersection.height; 
					}
					if(player.upperLeftCornerX > point.x)
					{
						player.upperLeftCornerX = player.upperLeftCornerX - intersection.width;
					}
					if(player.upperLeftCornerY > point.y)
					{
						player.upperLeftCornerY = player.upperLeftCornerY - intersection.height;
					}
							
				}
				
			}

The player object is then updated using the methods from the player class:




		public void draw()
		{
			
			glColor3f(0, 0, 1);
			glBegin(GL_QUADS);
			glVertex2i(upperLeftCornerX, upperLeftCornerY);
			glVertex2i(upperRightCornerX, upperRightCornerY);
			glVertex2i(lowerRightCornerX, lowerRightCornerY);
			glVertex2i(lowerLeftCornerX, lowerLeftCornerY);
			glEnd();
		}
		

and:



		void updatePosition(int dX, int dY)
		{
			upperLeftCornerX += dX;
			upperRightCornerX += dX;
			lowerRightCornerX += dX;
			lowerLeftCornerX += dX;
			upperLeftCornerY += dY;
			upperRightCornerY += dY;
			lowerRightCornerY += dY;
			lowerLeftCornerY += dY;
		}

The code compiles okay and the movement system works fine, but the rectangle representing the player stubbornly refuses to stop moving when it hits the scenery. I really have no idea what’s wrong with my system. I would be happy to provide more code and grateful for any help that could be provided.