[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] JList fix
From: |
Roman Kennke |
Subject: |
Re: [cp-patches] JList fix |
Date: |
Sat, 26 Feb 2005 18:10:37 +0100 |
I committed this optimized fix for JList.
Cheers,
Roman
Index: ChangeLog
===================================================================
RCS file: /cvsroot/classpath/classpath/ChangeLog,v
retrieving revision 1.3262
diff -u -u -r1.3262 ChangeLog
--- ChangeLog 25 Feb 2005 12:32:20 -0000 1.3262
+++ ChangeLog 26 Feb 2005 17:02:23 -0000
@@ -1,3 +1,9 @@
+2005-02-26 Roman Kennke <address@hidden>
+
+ * javax/swing/plaf/basic/BasicListUI
+ (updateLayoutState,paint): make BasicListUI aware of the
+ width of the rendered JList
+
2005-02-25 Mark Wielaard <address@hidden>
* NEWS: Add 0.14 release date.
Index: javax/swing/plaf/basic/BasicListUI.java
===================================================================
RCS
file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicListUI.java,v
retrieving revision 1.10
diff -u -u -r1.10 BasicListUI.java
--- javax/swing/plaf/basic/BasicListUI.java 22 Oct 2004 12:44:00 -0000
1.10
+++ javax/swing/plaf/basic/BasicListUI.java 26 Feb 2005 17:02:38 -0000
@@ -44,6 +44,9 @@
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Rectangle;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.awt.event.ComponentListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
@@ -71,6 +74,22 @@
*/
public class BasicListUI extends ListUI
{
+
+ /**
+ * A helper class which listens for address@hidden ComponentEvent}s from
+ * the JList.
+ */
+ class ComponentHandler extends ComponentAdapter {
+
+ /**
+ * Called when the component is hidden. Invalidates the internal
+ * layout.
+ */
+ public void componentResized(ComponentEvent ev) {
+ BasicListUI.this.damageLayout();
+ }
+ }
+
/**
* A helper class which listens for address@hidden FocusEvents}
* from the JList.
@@ -296,6 +315,10 @@
/** The property change listener listening to the list. */
PropertyChangeHandler propertyChangeListener;
+ /** The component listener that receives notification for resizing
the
+ * JList component.*/
+ ComponentListener componentListener;
+
/** Saved reference to the list this UI was created for. */
JList list;
@@ -437,6 +460,7 @@
Dimension dim = flyweight.getPreferredSize();
cellHeights[i] = dim.height;
cellWidth = Math.max(cellWidth, dim.width);
+ cellWidth = Math.max(cellWidth, list.getSize().width);
}
}
else
@@ -481,6 +505,7 @@
listSelectionListener = new ListSelectionHandler();
mouseInputListener = new MouseInputHandler();
propertyChangeListener = new PropertyChangeHandler();
+ componentListener = new ComponentHandler();
updateLayoutStateNeeded = 1;
}
@@ -527,6 +552,7 @@
list.addMouseListener(mouseInputListener);
list.addMouseMotionListener(mouseInputListener);
list.addPropertyChangeListener(propertyChangeListener);
+ list.addComponentListener(componentListener);
}
/**
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil