if (getParent() instanceof JViewport) return getParent().getWidth() > getPreferredSize().width;
boolean res = false;; Container c = getParent(); if (c instanceof JViewport) res = ((JViewport) c).getExtentSize().width > getPreferredSize().width;
  public boolean getScrollableTracksViewportWidth()  {    if (getParent() instanceof JViewport)      return getParent().getWidth() > getPreferredSize().width;    return false;  }