code: @Override
      public boolean getScrollableTracksViewportWidth() {
          Component parent = getParent();
          ComponentUI myui = getUI();
  
          return parent == null || (myui.getPreferredSize(this).width <= parent.getSize().width);
      }
docs: to preserve the full width of the text