Swing/HeaderRatio のバックアップ差分(No.5)
- バックアップ一覧
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- バックアップ を表示
- Swing/HeaderRatio へ行く。
- 1 (2005-11-28 (月) 18:26:47)
- 2 (2005-12-06 (火) 12:36:48)
- 3 (2005-12-16 (金) 17:21:37)
- 4 (2006-01-12 (木) 17:48:28)
- 5 (2006-02-27 (月) 16:00:42)
- 6 (2006-02-28 (火) 11:42:21)
- 7 (2006-03-24 (金) 23:10:19)
- 8 (2006-06-20 (火) 20:35:58)
- 9 (2006-11-10 (金) 12:52:29)
- 10 (2007-03-16 (金) 00:35:03)
- 11 (2007-05-10 (木) 10:37:27)
- 12 (2011-01-11 (火) 01:44:45)
- 13 (2011-03-02 (水) 18:21:40)
- 14 (2013-03-21 (木) 16:02:10)
- 15 (2013-04-06 (土) 05:04:24)
- 16 (2013-04-06 (土) 20:09:54)
- 17 (2014-09-27 (土) 02:18:41)
- 18 (2014-11-19 (水) 01:54:27)
- 19 (2015-03-09 (月) 14:46:02)
- 20 (2015-03-16 (月) 17:28:33)
- 21 (2015-03-18 (水) 18:49:18)
- 22 (2016-01-12 (火) 17:58:03)
- 23 (2017-06-23 (金) 12:48:24)
- 24 (2018-06-26 (火) 13:10:05)
- 25 (2020-06-11 (木) 22:57:37)
- 26 (2021-11-27 (土) 13:30:44)
- 追加された行はこの色です。
- 削除された行はこの色です。
#navi(../)
*TableColumnの幅を比率で設定 [#s3d330d1]
>編集者:[[Terai Atsuhiro>terai]]~
作成日:2005-11-28~
更新日:&lastmod;
#contents
**概要 [#n7b8933d]
TableColumnの幅を比率で設定します。
http://terai.xrea.jp/swing/headerratio/screenshot.png
**サンプルコード [#dc125241]
TableColumn col0 = table.getColumnModel().getColumn(0);
TableColumn col1 = table.getColumnModel().getColumn(1);
TableColumn col2 = table.getColumnModel().getColumn(2);
int w = table.getBounds(null).width;
if(w==0) w = 512;
int wr = list[0]+list[1]+list[2];
col0.setMaxWidth(list[0]*w/wr);
col1.setMaxWidth(list[1]*w/wr);
col2.setMaxWidth(list[2]*w/wr);
table.revalidate();
-[[サンプルを起動>http://terai.xrea.jp/swing/headerratio/sample.jnlp]]
-[[jarファイル>http://terai.xrea.jp/swing/headerratio/sample.jar]]
-[[ソース>http://terai.xrea.jp/swing/headerratio/src.zip]]
**解説 [#r3b250ae]
上記のサンプルでは、コロン区切りで入力した比率にしたがって、ヘッダカラムの幅を調整するようになっています。
フレームのサイズを変更しても、カラムの比率は保存されます。
TableColumn#setMaxWidthメソッドでカラムの幅を指定しているので、マウスのドラッグによるサイズの変更はできません。
//**参考リンク
**コメント [#f4b5dfe7]
#comment