From 67407b3e8b12ec52addf498dcf83f6cdd6bb4621 Mon Sep 17 00:00:00 2001 From: weisj Date: Tue, 20 Oct 2020 01:05:38 +0200 Subject: [PATCH] Ensure any controls of parents are made visible if possible when navigating JTree. --- .../weisj/darklaf/ui/tree/DarkTreeUI.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java index 9647cb39..061ec31c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/tree/DarkTreeUI.java @@ -694,17 +694,15 @@ public class DarkTreeUI extends BasicTreeUI implements PropertyChangeListener, C protected void scrollRowToVisible(final JTree tree, final int row) { Rectangle bounds = tree.getRowBounds(row); - if (!isLeaf(tree, row)) { - boolean expanded = tree.isExpanded(row); - BasicTreeUI ui = DarkUIUtil.getUIOfType(tree.getUI(), BasicTreeUI.class); - if (ui != null) { - Icon icon = expanded ? ui.getExpandedIcon() : ui.getCollapsedIcon(); - boolean ltr = tree.getComponentOrientation().isLeftToRight(); - int ident = ui.getRightChildIndent(); - int extra = ident - 1 + icon.getIconWidth() / 2; - if (ltr) bounds.x -= extra; - bounds.width += extra; - } + boolean expanded = tree.isExpanded(row); + BasicTreeUI ui = DarkUIUtil.getUIOfType(tree.getUI(), BasicTreeUI.class); + if (ui != null) { + Icon icon = expanded ? ui.getExpandedIcon() : ui.getCollapsedIcon(); + boolean ltr = tree.getComponentOrientation().isLeftToRight(); + int ident = ui.getRightChildIndent(); + int extra = ident - 1 + icon.getIconWidth() / 2; + if (ltr) bounds.x -= extra; + bounds.width += extra; } tree.scrollRectToVisible(bounds); }