Swing/IntercellSpacing のバックアップ(No.1)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- ソース を表示
- Swing/IntercellSpacing へ行く。
- 1 (2012-12-21 (金) 19:07:12)
- 2 (2013-08-17 (土) 01:00:37)
- 3 (2013-12-12 (木) 17:33:59)
- 4 (2015-01-14 (水) 15:42:56)
- 5 (2016-08-02 (火) 14:18:08)
- 6 (2016-11-22 (火) 21:00:52)
- 7 (2017-11-28 (火) 13:50:59)
- 8 (2019-07-30 (火) 13:54:24)
- 9 (2021-03-31 (水) 02:36:34)
- 10 (2023-10-24 (火) 22:41:44)
- 11 (2025-01-03 (金) 08:57:02)
- 12 (2025-01-03 (金) 09:01:23)
- 13 (2025-01-03 (金) 09:02:38)
- 14 (2025-01-03 (金) 09:03:21)
- 15 (2025-01-03 (金) 09:04:02)
TITLE:JTableの罫線の有無とセルの内余白を変更
Posted by aterai at 2011-05-30
JTableの罫線の有無とセルの内余白を変更
JTableの罫線の表示非表示とセルの内余白を変更します。
- &jnlp;
- &jar;
- &zip;
サンプルコード
Dimension d = table.getIntercellSpacing();
table.setShowVerticalLines(false);
table.setIntercellSpacing(new Dimension(0,d.height));
//table.setShowHorizontalLines(false);
//table.setIntercellSpacing(new Dimension(d.width,0));
View in GitHub: Java, Kotlin解説
JTableの罫線を非表示にしてもセルの内余白が0でない場合、選択状態でその内余白が表示されるので、上記のサンプルでは、JTable#setShowVerticalLines(boolean)などと一緒に、JTable#setIntercellSpacing(Dimension)で余白を0に切り替えています。
- 罫線
- JTable#setShowVerticalLines(boolean);
- JTable#setShowHorizontalLines(boolean);
- セルの内余白
- JTable#setIntercellSpacing(Dimension intercellSpacing);
- JTable#setRowMargin(intercellSpacing.height);
- JTable#getColumnModel().setColumnMargin(intercellSpacing.width);
- JTable#setIntercellSpacing(Dimension intercellSpacing);