Terai Atsuhiro 2023-07-15 (土) 22:14:03

http://terai.xrea.jp/swing/autoscroll/screenshot.png

private void autoScroll(Point ptLabel) {
  Point ptScroll = SwingUtilities.convertPoint(label, ptLabel, scroll);
  int iv = (int) scroll.getPreferredSize().getHeight();
  if(ptScroll.y < iv/2) {
    rect.setRect(0, ptLabel.y-ptScroll.y-SCROLL, 0, SCROLL);
    flg = true;
  }else{
    rect.setRect(0, ptLabel.y-ptScroll.y+iv+SCROLL, 0, SCROLL);
    flg = false;
  }
  scroller.start();
}

Swing/StyleConstants