Skip to content

Commit

Permalink
Fix some tree UI issues on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
m-dzianishchyts committed Jun 25, 2024
1 parent f711482 commit 52543d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ private void overrideUIDefaults() {
UIManager.put("SplitPane.border", BorderFactory.createEmptyBorder());
UIManager.put("SplitPane.background", darkGrey);
UIManager.put("Tree.rendererFillBackground", Boolean.TRUE);
UIManager.put("Tree.paintLines", Boolean.FALSE);
UIManager.put("ComboBox.background", Color.WHITE);
UIManager.put("ComboBox.selectionBackground", darkGrey);
UIManager.put("ComboBox.selectionForeground", Color.BLACK);
UIManager.put("CheckBox.background", Color.WHITE);
UIManager.put("Tree.background", Color.WHITE);
UIManager.put("Tree.selectionForeground", Color.BLACK);
UIManager.put("Tree.selectionBackground", lightGrey);
UIManager.put("Tree.selectionBorderColor", lightGrey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
*/
public class CheckBoxTreeCellRenderer extends JCheckBox implements TreeCellRenderer {

private static final String TREE_SELECTION_BACKGROUND = "Tree.selectionBackground";
private static final String TREE_BACKGROUND = "Tree.background";

protected final TreeCellRenderer defaultRenderer;

public CheckBoxTreeCellRenderer() {
Expand All @@ -49,11 +52,8 @@ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean
}
CheckBoxNodeData data = ((CheckBoxNodeData) node.getUserObject());

if (data.getState() != CheckBoxNodeData.State.INDETERMINATE) {
setSelected(data.isSelected());
} else {
setSelected(false);
}
setBackground(UIManager.getColor(selected ? TREE_SELECTION_BACKGROUND : TREE_BACKGROUND));
setSelected(data.getState() != CheckBoxNodeData.State.INDETERMINATE && data.isSelected());

return this;
}
Expand Down

0 comments on commit 52543d1

Please sign in to comment.