Swing/TreePaintLines のバックアップソース(No.5)
- バックアップ一覧
- 差分 を表示
- 現在との差分 を表示
- 現在との差分 - Visual を表示
- バックアップ を表示
- Swing/TreePaintLines へ行く。
- 1 (2008-02-04 (月) 16:09:01)
- 2 (2008-03-18 (火) 14:34:52)
- 3 (2012-09-09 (日) 09:37:18)
- 4 (2013-08-02 (金) 20:57:26)
- 5 (2013-09-07 (土) 00:30:27)
- 6 (2014-11-25 (火) 03:03:31)
- 7 (2015-01-13 (火) 11:29:05)
- 8 (2015-05-21 (木) 19:41:15)
- 9 (2016-08-08 (月) 02:11:21)
- 10 (2017-10-03 (火) 13:52:29)
- 11 (2019-04-09 (火) 15:45:42)
- 12 (2021-01-15 (金) 11:48:11)
- 13 (2023-07-28 (金) 17:12:10)
TITLE:JTreeの水平垂直線を表示しない #navi(../) #tags(JTree, UIManager) RIGHT:Posted by &author(aterai); at 2008-02-04 * JTreeの水平垂直線を表示しない [#la642829] ``JTree``のアイコンを繋ぐ水平垂直線の表示の有無を切り替えます。 - &jnlp; - &jar; - &zip; #ref(https://lh3.googleusercontent.com/_9Z4BYR88imo/TQTWNxTrfYI/AAAAAAAAAo4/xS9RjkcNYYM/s800/TreePaintLines.png) ** サンプルコード [#a4057d44] #code(link){{ final JTree tree = new JTree(); add(new JCheckBox(new AbstractAction("Tree.paintLines") { @Override public void actionPerformed(ActionEvent e) { if(((JCheckBox)e.getSource()).isSelected()) { UIManager.put("Tree.paintLines", Boolean.TRUE); }else{ UIManager.put("Tree.paintLines", Boolean.FALSE); } tree.updateUI(); // 左のJTreeだけ更新 //SwingUtilities.updateComponentTreeUI(MainPanel.this); } }), BorderLayout.NORTH); }} ** 解説 [#d8a44352] 上記のサンプルでは、左の``JTree``の水平線などの表示を、``UIManager.put("Tree.paintLines", Boolean.FALSE);``で切り替えています(右は常に非表示)。 元々、線を表示しない``GTKLookAndFeel``などでは、``UIManager.put("Tree.paintLines", Boolean.TRUE);``としても線は描画されないようです。 複数の``JTree``の表示を個別に切り替えたい場合は、[https://forums.oracle.com/message/5774205 Hide horizontal and vertical lines in a JTree | Oracle Forums]で、Michael_Dunn さんが投稿(``2007/10/24 2:42``)したコードのように、``BasicTreeUI#paintHorizontalLine``メソッドなどをオーバーライドする方法もあります。 ** 参考リンク [#ld863a92] - [https://forums.oracle.com/message/5774205 Hide horizontal and vertical lines in a JTree | Oracle Forums] ** コメント [#v77a9c8a] #comment