Beispiel #1
0
  public void paintViewport(Graphics g, JViewport c) {
    if (!browser.isPreviewColumnFilled()) {
      Dimension vs = c.getSize();
      Dimension bs = browser.getSize();

      JScrollBar vb = getVerticalBar();

      g.setColor(Color.black);
      Dimension ss = vb.getPreferredSize();

      // Paint scroll bar tracks at the right to fill the viewport
      if (bs.width < vs.width) {
        int fixedCellWidth = browser.getFixedCellWidth();

        // FIXME - Apparently we have to do layout manually, because
        //         invoking cellRendererPane.paneComponent with
        //         "shouldValidate" set to true does not appear to have
        //         the desired effect.
        try {
          vb.setSize(ss.width, vs.height);
          vb.doLayout();
        } catch (NullPointerException e) {
          // We get NPE here in JDK 1.3. We ignore it.
        }

        for (int x = browser.getWidth() + fixedCellWidth;
            x < vs.width;
            x += fixedCellWidth + ss.width) {
          getCellRendererPane().paintComponent(g, vb, c, x, 0, ss.width, vs.height, false);
        }
      }
    }
  }
  private int getHeightOffset(FilePanel fp) {
    JScrollPane scrollPane;
    JViewport viewport;
    int offset;
    int unitIncrement;

    scrollPane = fp.getScrollPane();
    viewport = scrollPane.getViewport();

    offset = viewport.getSize().height / 2;
    unitIncrement = scrollPane.getHorizontalScrollBar().getUnitIncrement();
    offset = offset - (offset % unitIncrement);

    return offset;
  }