I am doing some calculations and drawing based on the width/height of my JPanel (640x480), but when I output the actual position of my mouse, I notice that it has actual bounds of (622x441). Why is this, and how can I compensate for it?
Here is my constructor of GamePanel
public GamePanel(){
wallBoard = new WallBoard();
player = new Player(100, 100);
Map<String, GameObject> startingEquipment = new HashMap<String, GameObject>();
startingEquipment.put("Sword and Sheild", new Sword(player.getX(), player.getY()));
player.equip(startingEquipment);
enemy = new Enemy(10, 10);
objects.add(player);
objects.add(enemy);
mouseSelection = new MouseSelection();
setSize(new Dimension(640, 480));
setDoubleBuffered(true);
setFocusable(true);
addKeyListener(this);
addMouseListener(this);
addMouseMotionListener(this);
frame = new GameFrame();
frame.pack(); //this makes the window just the bar at the top
//frame.setUndecorated(true); crashes the program
frame.addKeyListener(this);
frame.add(this);
t = new Thread(this);
t.start();
hud = new HeadsUpDisplay(getWidth(), getHeight());
}