summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/JList.java
diff options
context:
space:
mode:
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-23 21:31:04 +0000
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-23 21:31:04 +0000
commit947b8814056ea2fba6bbcfab86591f74bffc0311 (patch)
tree3ca4b2e68dc14c3128b9c781d23f1d0b1f2bee49 /libjava/classpath/javax/swing/JList.java
parent49792907376493f0939563eb0219b96a48f1ae3b (diff)
downloadppe42-gcc-947b8814056ea2fba6bbcfab86591f74bffc0311.tar.gz
ppe42-gcc-947b8814056ea2fba6bbcfab86591f74bffc0311.zip
Imported Classpath 0.18.
* sources.am, Makefile.in: Updated. * Makefile.am (nat_source_files): Removed natProxy.cc. * java/lang/reflect/natProxy.cc: Removed. * gnu/classpath/jdwp/VMFrame.java, gnu/classpath/jdwp/VMIdManager.java, gnu/classpath/jdwp/VMVirtualMachine.java, java/lang/reflect/VMProxy.java: New files. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * scripts/makemake.tcl (verbose): Add gnu/java/awt/peer/qt to BC list. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/java/net/DefaultContentHandlerFactory.java (getContent): Remove ClasspathToolkit references. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * gnu/awt/xlib/XCanvasPeer.java: Add new peer methods. * gnu/awt/xlib/XFramePeer.java: Likewise. * gnu/awt/xlib/XGraphicsConfiguration.java: Likewise. 2005-09-23 Thomas Fitzsimmons <fitzsim@redhat.com> * Makefile.am (libgcjawt_la_SOURCES): Remove jawt.c. Add classpath/native/jawt/jawt.c. * Makefile.in: Regenerate. * jawt.c: Remove file. * include/Makefile.am (tool_include__HEADERS): Remove jawt.h and jawt_md.h. Add ../classpath/include/jawt.h and ../classpath/include/jawt_md.h. * include/Makefile.in: Regenerate. * include/jawt.h: Regenerate. * include/jawt_md.h: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104586 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/javax/swing/JList.java')
-rw-r--r--libjava/classpath/javax/swing/JList.java59
1 files changed, 41 insertions, 18 deletions
diff --git a/libjava/classpath/javax/swing/JList.java b/libjava/classpath/javax/swing/JList.java
index fb8d18b8565..92fe1ccfa67 100644
--- a/libjava/classpath/javax/swing/JList.java
+++ b/libjava/classpath/javax/swing/JList.java
@@ -574,7 +574,7 @@ public class JList extends JComponent implements Accessible, Scrollable
ComponentOrientation or = getComponentOrientation();
Rectangle r = getVisibleRect();
if (or == ComponentOrientation.RIGHT_TO_LEFT)
- r.translate((int) r.getWidth(), 0);
+ r.translate((int) r.getWidth() - 1, 0);
return getUI().locationToIndex(this, r.getLocation());
}
@@ -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,17 +604,20 @@ 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()
{
ComponentOrientation or = getComponentOrientation();
Rectangle r = getVisibleRect();
- r.translate(0, (int) r.getHeight());
+ r.translate(0, (int) r.getHeight() - 1);
if (or == ComponentOrientation.LEFT_TO_RIGHT)
- r.translate((int) r.getWidth(), 0);
- return getUI().locationToIndex(this, r.getLocation());
+ r.translate((int) r.getWidth() - 1, 0);
+ if (getUI().locationToIndex(this, r.getLocation()) == -1
+ && indexToLocation(getModel().getSize() - 1).y < r.y)
+ return getModel().getSize() - 1;
+ return getUI().locationToIndex(this, r.getLocation());
}
/**
@@ -1030,20 +1032,41 @@ public class JList extends JComponent implements Accessible, Scrollable
*/
public Dimension getPreferredScrollableViewportSize()
{
+ //If the layout orientation is not VERTICAL, then this will
+ //return the value from getPreferredSize. The current ListUI is
+ //expected to override getPreferredSize to return an appropriate value.
+ if (getLayoutOrientation() != VERTICAL)
+ return getPreferredSize();
+
+ if (fixedCellHeight != -1 && fixedCellWidth != -1)
+ return new Dimension(fixedCellWidth, getModel().getSize() *
+ fixedCellHeight);
- Dimension retVal = getPreferredSize();
- if (getLayoutOrientation() == VERTICAL)
+ int prefWidth, prefHeight;
+ if (fixedCellWidth != -1)
+ prefWidth = fixedCellWidth;
+ else
{
- if (fixedCellHeight != -1)
- {
- if (fixedCellWidth != -1)
- {
- int size = getModel().getSize();
- retVal = new Dimension(fixedCellWidth, size * fixedCellHeight);
- } // TODO: add else clause (preferredSize is ok for now)
- } // TODO: add else clause (preferredSize is ok for now)
+ prefWidth = 0;
+ int size = getModel().getSize();
+ for (int i = 0; i < size; i++)
+ if (getCellBounds(i, i).width > prefWidth)
+ prefWidth = getCellBounds(i, i).width;
}
- return retVal;
+
+ if (getModel().getSize() == 0 && fixedCellWidth == -1)
+ return new Dimension(256, 16 * getVisibleRowCount());
+ else if (getModel().getSize() == 0)
+ return new Dimension (fixedCellWidth, 16 * getVisibleRowCount());
+
+ if (fixedCellHeight != -1)
+ prefHeight = fixedCellHeight;
+ else
+ {
+ prefHeight = getVisibleRowCount() * getCellBounds
+ (getFirstVisibleIndex(), getFirstVisibleIndex()).height;
+ }
+ return new Dimension (prefWidth, prefHeight);
}
/**
OpenPOWER on IntegriCloud