Skip to content

Commit

Permalink
Improves TreeNodeRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed May 15, 2015
1 parent 71e177a commit 445643e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions app/src/main/groovy/jd/gui/view/renderer/TreeNodeRenderer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class TreeNodeRenderer implements TreeCellRenderer {
Color backgroundSelectionColor
Color textNonSelectionColor
Color backgroundNonSelectionColor
Color textDisabledColor
Color backgroundDisabledColor

JPanel panel
JLabel icon, label
Expand All @@ -37,14 +39,14 @@ class TreeNodeRenderer implements TreeCellRenderer {
backgroundSelectionColor = UIManager.getColor("Tree.selectionBackground")
textNonSelectionColor = UIManager.getColor("Tree.textForeground")
backgroundNonSelectionColor = UIManager.getColor("Tree.textBackground")
textDisabledColor = UIManager.getColor("Tree.disabledText")
backgroundDisabledColor = UIManager.getColor("Tree.disabled")
Insets margins = UIManager.getInsets("Tree.rendererMargins")

icon.foreground = textNonSelectionColor
icon.opaque = label.opaque = false
icon.border = BorderFactory.createEmptyBorder(0, 0, 0, 2)

label.background = backgroundSelectionColor

if (margins) {
label.border = BorderFactory.createEmptyBorder(margins.top, margins.left, margins.bottom, margins.right)
} else {
Expand All @@ -67,7 +69,13 @@ class TreeNodeRenderer implements TreeCellRenderer {
}

if (selected) {
label.foreground = textSelectionColor
if (hasFocus) {
label.foreground = textSelectionColor
label.background = backgroundSelectionColor
} else {
label.foreground = textDisabledColor
label.background = backgroundDisabledColor
}
label.opaque = true
} else {
label.foreground = textNonSelectionColor
Expand Down

0 comments on commit 445643e

Please sign in to comment.