I'm trying to make my first game and I'm having a strange problem. In my panel class I have
private static final int WIDTH = 640;
private static final int HEIGHT = 480;
and I use these for both creating the panel
setPreferredSize(new Dimension(WIDTH, HEIGHT));
and creating an image to draw to the screen.
image = createImage(WIDTH,HEIGHT);
But for some reason when I run the program it makes the panel 650 by 490 which is 10 pixels too big in both directions. I have no idea what is causing this. I have fixed it by changing the panel constructor to
setPreferredSize(new Dimension(WIDTH-10, HEIGHT-10));
but I don't understand why I need to be doing such a thing.
I've tried using different dimensions and no matter what I pick, both sides are always 10 pixels too big, except that the width never goes below 118. When I tried WIDTH = 1 and HEIGHT = 1, I ran my program and it gave me a panel that was 118 by 11.