void (JViewport viewport, int value) { Point position = viewport.getViewPosition(); position.x = Math.max(0, Math.min(value, viewport.getViewSize().width - viewport.getExtentSize().width)); viewport.setViewPosition(position); }