diff options
Diffstat (limited to 'libjava/javax/swing/plaf/basic/BasicListUI.java')
-rw-r--r-- | libjava/javax/swing/plaf/basic/BasicListUI.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/libjava/javax/swing/plaf/basic/BasicListUI.java b/libjava/javax/swing/plaf/basic/BasicListUI.java index b356bdf2a9a..bd5c53b04ff 100644 --- a/libjava/javax/swing/plaf/basic/BasicListUI.java +++ b/libjava/javax/swing/plaf/basic/BasicListUI.java @@ -121,7 +121,6 @@ public class BasicListUI extends ListUI */ public void contentsChanged(ListDataEvent e) { - // System.err.println(this + ".contentsChanged(" + e + ")"); BasicListUI.this.damageLayout(); } @@ -132,7 +131,6 @@ public class BasicListUI extends ListUI */ public void intervalAdded(ListDataEvent e) { - // System.err.println(this + ".intervalAdded(" + e + ")"); BasicListUI.this.damageLayout(); } @@ -143,7 +141,6 @@ public class BasicListUI extends ListUI */ public void intervalRemoved(ListDataEvent e) { - // System.err.println(this + ".intervalRemoved(" + e + ")"); BasicListUI.this.damageLayout(); } } @@ -161,7 +158,6 @@ public class BasicListUI extends ListUI */ public void valueChanged(ListSelectionEvent e) { - // System.err.println(this + ".valueChanged(" + e + ")"); } } @@ -189,12 +185,10 @@ public class BasicListUI extends ListUI */ public void mousePressed(MouseEvent event) { - // System.err.println("got mouse click event " + event); int row = BasicListUI.this.convertYToRow(event.getY()); if (row == -1) return; - // System.err.println("clicked on row " + row); BasicListUI.this.list.setSelectedIndex(row); } @@ -262,7 +256,6 @@ public class BasicListUI extends ListUI */ public void propertyChange(PropertyChangeEvent e) { - // System.err.println(this + ".propertyChange(" + e + ")"); if (e.getSource() == BasicListUI.this.list) { if (e.getOldValue() != null && e.getOldValue() instanceof ListModel) @@ -357,6 +350,8 @@ public class BasicListUI extends ListUI */ public Rectangle getCellBounds(JList l, int index1, int index2) { + maybeUpdateLayoutState(); + if (l != list || cellWidth == -1) return null; @@ -366,6 +361,7 @@ public class BasicListUI extends ListUI getRowHeight(lo)); Rectangle hibounds = new Rectangle(0, convertRowToY(hi), cellWidth, getRowHeight(hi)); + return lobounds.union(hibounds); } @@ -408,7 +404,6 @@ public class BasicListUI extends ListUI { int h = getRowHeight(row); - // System.err.println("convertYToRow(" + y0 + ") vs. " + h); if (y0 < h) return row; y0 -= h; @@ -468,7 +463,6 @@ public class BasicListUI extends ListUI */ void maybeUpdateLayoutState() { - // System.err.println(this + ".maybeUpdateLayoutState()"); if (updateLayoutStateNeeded != 0) { updateLayoutState(); @@ -576,7 +570,6 @@ public class BasicListUI extends ListUI installDefaults(); installListeners(); installKeyboardActions(); - // System.err.println(this + ".installUI()"); maybeUpdateLayoutState(); } @@ -618,11 +611,9 @@ public class BasicListUI extends ListUI */ public Dimension getPreferredSize(JComponent c) { - maybeUpdateLayoutState(); if (list.getModel().getSize() == 0) return new Dimension(0, 0); - int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize()); - Rectangle bounds = getCellBounds(list, 0, nrows - 1); + Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1); return bounds.getSize(); } @@ -678,7 +669,7 @@ public class BasicListUI extends ListUI */ public void paint(Graphics g, JComponent c) { - int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize()); + int nrows = list.getModel().getSize(); if (nrows == 0) return; @@ -687,11 +678,13 @@ public class BasicListUI extends ListUI ListModel model = list.getModel(); ListSelectionModel sel = list.getSelectionModel(); int lead = sel.getLeadSelectionIndex(); + Rectangle clip = g.getClipBounds(); paintBackground(g, list); for (int row = 0; row < nrows; ++row) { Rectangle bounds = getCellBounds(list, row, row); + if (bounds.intersects(clip)) paintCell(g, row, bounds, render, model, sel, lead); } } |