Summary
JTree
のインデント量を指定して子ノードが描画される位置を変更します。
Screenshot

Advertisement
Source Code Examples
UIManager.put("Tree.leftChildIndent", 0);
UIManager.put("Tree.rightChildIndent", 0);
View in GitHub: Java, KotlinExplanation
上記のサンプルでは、JTree
の以下の2
つインデント量をUIManager.put(...)
で指定して子ノードが描画される位置を変更するテストを行っています。
Tree.leftChildIndent
- 親ノードの左端と垂直破線が描画される位置の間隔
Tree.rightChildIndent
- 垂直破線から子ノードが描画される位置の間隔
Tree.leftChildIndent
とTree.rightChildIndent
の合計から子ノードのインデント量になるので、この合計が0
になるように設定すると、デフォルトのJList
風に各ノードを表示するJTree
が作成可能