diff --git a/ts3-client/swing/src/main/java/com/ts3client/ui/DropIndicatorTree.java b/ts3-client/swing/src/main/java/com/ts3client/ui/DropIndicatorTree.java index 4ac9063..ae78043 100644 --- a/ts3-client/swing/src/main/java/com/ts3client/ui/DropIndicatorTree.java +++ b/ts3-client/swing/src/main/java/com/ts3client/ui/DropIndicatorTree.java @@ -71,6 +71,9 @@ final class DropIndicatorTree extends JTree { addMouseMotionListener(hover); addMouseListener(hover); addMouseWheelListener(hover); + // The selected row is filled across the full width below, before the rows + // themselves are drawn, so this component must not clear its own background. + setOpaque(false); } /** @@ -129,6 +132,10 @@ final class DropIndicatorTree extends JTree { @Override protected void paintComponent(Graphics g) { + Rectangle clip = g.getClipBounds(); + g.setColor(getBackground()); + g.fillRect(clip.x, clip.y, clip.width, clip.height); + paintSelection(g); super.paintComponent(g); paintBadges(g); paintHover(g); @@ -154,6 +161,22 @@ final class DropIndicatorTree extends JTree { g2.dispose(); } + /** + * Fills the selected row across the full width, in the colour the cell renderer + * puts behind the label itself, so the selection covers the whole line rather + * than stopping where the name ends. + */ + private void paintSelection(Graphics g) { + int[] rows = getSelectionRows(); + if (rows == null) return; + Rectangle visible = getVisibleRect(); + g.setColor(Theme.TREE_SELECTION); + for (int row : rows) { + Rectangle bounds = getRowBounds(row); + if (bounds != null) g.fillRect(visible.x, bounds.y, visible.width, bounds.height); + } + } + /** * Outlines the row under the pointer, across the full width the row occupies — * the same area a click on it acts on. Spacers, which nothing can be done with,