TITLE:JTableの行の高さを変更する
#navi(../)
*JTableの行の高さを変更する [#f76fb424]
Posted by [[terai]] at 2008-11-24

#contents

**概要 [#r2958ee8]
JTableの行の高さを変更して、マウスカーソルの下を魚眼レンズのように拡大します。

-&jnlp;
-&jar;
-&zip;

#screenshot

**サンプルコード [#h51cf8b6]
#code{{
public void mouseMoved(MouseEvent e) {
  int row = rowAtPoint(e.getPoint());
  if(prev_row==row) return;
  initRowHeigth(prev_height, row);
  prev_row = row;
}
public void initRowHeigth(int height, int ccRow) {
  int rowCount = getModel().getRowCount();
  int view_rc  = getViewableColoredRowCount(ccRow);
  int view_h   = 0; for(int i=0;i<view_rc;i++) view_h += fishEyeRowHeightList.get(i);
  int rest_rc  = rowCount - view_rc;
  int rest_h   = height - view_h;
  int rest_rh  = rest_h/rest_rc; rest_rh = rest_rh>0?rest_rh:1;
  int a        = rest_h - rest_rh*rest_rc;
  int index    = -1;
  for(int i=-rd2;i<rowCount;i++) {
    int crh;
    if(ccRow-rd2<=i && i<=ccRow+rd2) {
      index++;
      if(i<0) continue;
      crh = fishEyeRowHeightList.get(index);
    }else{
      if(i<0) continue;
      crh = rest_rh+(a>0?1:0);
      a = a-1;
    }
    setRowHeight(i, crh);
  }
}
}}

**解説 [#l87b6de9]
上記のサンプルでは、マウスカーソルの下の行の高さを、JTable#setRowHeight() メソッドを使って変更することで、魚眼レンズのように拡大するようになっています。

**参考リンク [#s1716c99]
-[[Fisheye Menus>http://www.cs.umd.edu/hcil/fisheyemenu/]]

**コメント [#e349a66c]
#comment