public void updateScrollBar()
   {
      int max = scrollBar.getModel().getMaximum();
      int min = scrollBar.getModel().getMinimum();
      int pos = scrollBar.getModel().getValue();
      int ext = scrollBar.getModel().getExtent();
      //
      if (max == ext)
         return;
      if (scrollBar.getValueIsAdjusting())
         return;
      //
      if ((scrollDirection == 0) && (pause == 0))
      {
         if (pos == min)
            scrollDirection = 1;
         else
            scrollDirection = -1;
      }
      else
         pause--;
      if (scrollDirection > 0)
      {
         pos += 4;
         if (pos + ext > max)
         {
            pos = max - ext;
            scrollDirection = 0;
            pause = 20;
         }
         scrollBar.setValue(pos);
      }
      else if (scrollDirection < 0)
      {
         pos -= 4;
         if (pos < min)
         {
            pos = min;
            scrollDirection = 0;
            pause = 20;
         }
         scrollBar.setValue(pos);
      }
   }