From 06b4343f986f22ff9fcfae7e15f6fb2dee8b7456 Mon Sep 17 00:00:00 2001 From: Audrius Meskauskas Date: Fri, 5 May 2006 08:07:57 +0000 Subject: 2006-05-05 Audrius Meskauskas * javax/swing/plaf/basic/BasicTreeUI.java (paint): Return early if there are no visible nodes to paint. --- ChangeLog | 5 +++++ javax/swing/plaf/basic/BasicTreeUI.java | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3379b692c..cc398753c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-05-05 Audrius Meskauskas + + * javax/swing/plaf/basic/BasicTreeUI.java (paint): Return early + if there are no visible nodes to paint. + 2006-05-05 David Gilbert * javax/swing/JOptionPane.java: API doc updates. diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java index bfbbffcdd..be61ccaec 100644 --- a/javax/swing/plaf/basic/BasicTreeUI.java +++ b/javax/swing/plaf/basic/BasicTreeUI.java @@ -1376,6 +1376,12 @@ public class BasicTreeUI public void paint(Graphics g, JComponent c) { JTree tree = (JTree) c; + + int rows = treeState.getRowCount(); + + if (rows == 0) + // There is nothing to do if the tree is empty. + return; Rectangle clip = g.getClipBounds(); @@ -1387,9 +1393,7 @@ public class BasicTreeUI int endIndex = tree.getClosestRowForLocation(clip.x + clip.width, clip.y + clip.height); - // Also paint dashes to the invisible nodes below: - int rows = treeState.getRowCount(); - + // Also paint dashes to the invisible nodes below. // These should be painted first, otherwise they may cover // the control icons. if (endIndex < rows) -- cgit v1.2.1