private static void setValue(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);
  }
private static void setValue(JViewport viewport, int value)