summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Balkissoon <abalkiss@redhat.com>2005-08-17 18:43:36 +0000
committerAnthony Balkissoon <abalkiss@redhat.com>2005-08-17 18:43:36 +0000
commit92ad7e112a830d3489155784472e3e7e8efa60cc (patch)
tree576993271439fe724203b76d42e35994f145fcef
parent145156655509efd34dc3bec1ffeab774b7fbfbe9 (diff)
downloadclasspath-92ad7e112a830d3489155784472e3e7e8efa60cc.tar.gz
2005-08-17 Anthony Balkissoon <abalkiss@redhat.com>
* javax/swing/JList.java: (indexToLocation): Implemented. (getLastVisibleIndex): If the last index in the list is showing and there is extra room at the bottom, return the last index, not -1.
-rw-r--r--ChangeLog7
-rw-r--r--javax/swing/JList.java10
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 1ffd26a87..b64bc7fa9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-08-17 Anthony Balkissoon <abalkiss@redhat.com>
+
+ * javax/swing/JList.java:
+ (indexToLocation): Implemented.
+ (getLastVisibleIndex): If the last index in the list is showing and
+ there is extra room at the bottom, return the last index, not -1.
+
2005-08-17 Lillian Angel <langel@redhat.com>
* javax/swing/plaf/basic/BasicTreeUI.java
diff --git a/javax/swing/JList.java b/javax/swing/JList.java
index 0e38fb1c8..c5ab60682 100644
--- a/javax/swing/JList.java
+++ b/javax/swing/JList.java
@@ -596,8 +596,7 @@ public class JList extends JComponent implements Accessible, Scrollable
* @return location of the cell located at the specified index in the list.
*/
public Point indexToLocation(int index){
- //FIXME: Need to implement.
- return null;
+ return getCellBounds(index, index).getLocation();
}
/**
@@ -605,7 +604,7 @@ public class JList extends JComponent implements Accessible, Scrollable
* {@link #visibleRect} property, depending on the {@link
* #componentOrientation} property.
*
- * @return The index of the first visible list cell, or <code>-1</code>
+ * @return The index of the last visible list cell, or <code>-1</code>
* if none is visible.
*/
public int getLastVisibleIndex()
@@ -615,7 +614,10 @@ public class JList extends JComponent implements Accessible, Scrollable
r.translate(0, (int) r.getHeight() - 1);
if (or == ComponentOrientation.LEFT_TO_RIGHT)
r.translate((int) r.getWidth() - 1, 0);
- return getUI().locationToIndex(this, r.getLocation());
+ if (getUI().locationToIndex(this, r.getLocation()) == -1
+ && indexToLocation(getModel().getSize() - 1).y < r.y)
+ return getModel().getSize() - 1;
+ return getUI().locationToIndex(this, r.getLocation());
}
/**