public void updateScrollBars() {
    if (vertical != null && visibleLines != 0) {
      vertical.setValues(firstLine,visibleLines,0,getLineCount());
      vertical.setUnitIncrement(2);
      vertical.setBlockIncrement(visibleLines);
    }

    //if (horizontal != null && width != 0) {
    if ((horizontal != null) && (painter.getWidth() != 0)) {
      //int value = horizontal.getValue();
      //System.out.println("updateScrollBars");
      //int width = painter.getWidth();
      int lineCount = getLineCount();
      int maxLineLength = 0;
      for (int i = 0; i < lineCount; i++) {
        int lineLength = getLineLength(i);
        if (lineLength > maxLineLength) {
          maxLineLength = lineLength;
        }
      }
      int charWidth = painter.getFontMetrics().charWidth('w');
      int width = maxLineLength * charWidth;
      int painterWidth = painter.getWidth();
      //System.out.println("max line len " + maxLineLength);
      //System.out.println("width " + width);
      //System.out.println("text area width " + painter.getWidth());

      // this was the default, but it's enormous
      //horizontal.setValues(-horizontalOffset,width,0,width * 5);

      // something more reasonable, though this is a bad solution
      //horizontal.setValues(-horizontalOffset,width,0,width * 2);

      // in general.. time to start looking at that other syntax pkg
      // since most code should fit the window horizontally, just use
      // the default settings for the width, this is a nicer solution
      // until a better update mechanism can be implemented [fry]

      //horizontal.setValues(0, width, 0, width);
                           //0, width - horizontalOffset);
      // works, from pre-75 versions of p5
      //horizontal.setValues(-horizontalOffset, width, 0, width);

      // gets weird when writing to the end of lines
      //horizontal.setValues(value, painterWidth, 0, width);

      // seems to work, implemented for 0075
      horizontal.setValues(-horizontalOffset, painterWidth, 0, width);

      //horizontal.setUnitIncrement(painter.getFontMetrics().charWidth('w'));
      horizontal.setUnitIncrement(charWidth);
      horizontal.setBlockIncrement(width / 2);
    }
  }