• category: swing folder: DrawsTreeFocus title: JTreeのノードがフォーカス状態になった場合のBorderを変更する tags: [JTree, UIManager, Border, Focus, LookAndFeel] author: aterai pubdate: 2014-06-16T01:26:31+09:00 description: JTreeのノードが選択されてフォーカス状態になった場合のBorderによる描画をUIManagerで変更します。 image: https://lh3.googleusercontent.com/-I62wWvQhdQI/U53BUsVLj9I/AAAAAAAACHk/SSHVLXv9m28/s800/DrawsTreeFocus.png

概要

JTreeのノードが選択されてフォーカス状態になった場合のBorderによる描画をUIManagerで変更します。

サンプルコード

UIManager.putBoolean("Tree.drawsFocusBorderAroundIcon", false);
UIManager.putBoolean("Tree.drawDashedFocusIndicator", false);
View in GitHub: Java, Kotlin

解説

  • Tree.drawsFocusBorderAroundIcon
    • trueの場合、JTreeのノードアイコンを囲むようにBorderが拡張される(背景色で塗りつぶされる範囲は変化しない)
    • MotifLookAndFeelの初期値はtrue
  • Tree.drawDashedFocusIndicator
    • trueの場合、JTreeのフォーカスの描画に使用するBorderが点線になる
    • WindowsLookAndFeelの初期値はtrue

コメント