object positioning

Hello

I was wanting to know if I am missing anything in my understanding of how java run an app and display the objects within the frame.
I trying to create a simple pong game with a round ball instead of a square ball.


	// Constant/variable for the game window width.
	public final static int GAME_WIDTH = 600;
	// Constant/variable for the game window height.
	public final static int GAME_HEIGHT = GAME_WIDTH / 4 * 3;

	// Encapsulates the height and the width into a single constant/variable.


	public final static Dimension GAME_SIZE = new Dimension(GAME_WIDTH,
			GAME_HEIGHT);

so if I understand how computer’s draw objects the initial starting point is the upper left hand corner of the objects bounding box?

if so why is my placement not being placed like it should be? Which should be drawn @ 589 x and 210 y but it is being drawn @ 579 x and 210 y. as shown in the picture.

with the CONSTANT PADDLE_WIDTH

http://s17.postimg.org/6pi3dv8kv/with_paddlewith.png

and when I remove the PADDLE_WIDTH CONSTANT I get the correct result but it should draw the right paddle off the screen at 599 x and 210 y instead of 589 x and 210 y like it does in the follow image.

http://s17.postimg.org/hb1ypvewf/wo_paddlewidth.png

SO I guess what I am asking is what is Java doing that I do not know about, and Am I correct with my thinking where the objects should be places on screen?

Thanks
Richard

What component are you sizing with GAME_WIDTH and GAME_HEIGHT?

If it’s the JFrame, notice that the JPanel inside of it is slightly smaller, to make room for the window border.

This would be much easier to talk about if you posted an MCVE instead of screenshots of your code.

Here is my complete code; It never seems no matter how concise I am with the post people always want more :slight_smile:

https://www.mediafire.com/?9vm0wac05lkzlcg I hope this helps out.

The only thing we really want is to be able to run your code. The best way for you to help with that is to post an MCVE- that’s not your whole project, but not a disconnected snippet. We should be able to copy and paste it (in one file if at all possible) directly from the forum to run it ourselves. After all, shouldn’t you make it as easy as possible for other people to help you?

But I would guess it’s exactly what I already mentioned- what are you setting the size of? If you’re setting the size of the JFrame, then the JPanel will be smaller.