// schroll the map using mouse @Override public void mouseDragged(MouseEvent e) { Point dragged = e.getPoint(); int x = dragged.x - pressed.x; int y = dragged.y - pressed.y; if (y > 0) { panel.decreaseScrollY(); } if (y < 0) { panel.increaseScrollY(); } if (x > 0) { panel.decreaseScrollX(); } if (x < 0) { panel.increaseScrollX(); } panel.repaint(); }