diff options
| author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-19 06:16:17 +0000 |
|---|---|---|
| committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-04-19 06:16:17 +0000 |
| commit | 7878167de36c868f3f4b0f507094bb155efbb199 (patch) | |
| tree | 1dca6700c6ae7fabc5104e3945bafaea71208f18 /libjava/javax/swing/JList.java | |
| parent | 6f09420fd46ad2ffaef9755bc346d687802d3648 (diff) | |
| download | ppe42-gcc-7878167de36c868f3f4b0f507094bb155efbb199.tar.gz ppe42-gcc-7878167de36c868f3f4b0f507094bb155efbb199.zip | |
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/JList.java
(getPreferredScrollableViewportSize):
The previous implementation was merely guessing the size,
now it respects layoutOrientation, visibleRowCount
and preferredSize.
(getScrollableTracksViewportHeight):
Reimplemented so that layoutOrientation, visibleRowCount
and preferred size are respected.
(getScrollableTracksViewportWidth):
Reimplemented so that layoutOrientation, visibleRowCount
and preferred size are respected.
* javax/swing/plaf/basic/BasicListUI.java
(getPreferredSize):
Improved calculation of preferredSize when JList is
set to HORIZONTAL_WRAP or VERTICAL_WRAP.
(getCellBounds):
The previous implementation assumed a layoutOrientation of
JList.VERTICAL, now also ok with JList.HORIZONTAL_WRAP and
JList.VERTICAL_WRAP.
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI.java
(paintCell): use CellRendererPane for painting the cells.
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI:
fixed modifiers of several fields, methods and inner
classes to match the 'spec'.
(getMaximumSize): removed. It's not in the spec and the
implementations was superfluous.
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI:
make BasicListUI capable of wrapping lists
(layoutOrientation property of javax.swing.JList)
2005-04-19 Roman Kennke <roman@ontographics.com>
* javax/swing/plaf/basic/BasicListUI
(updateLayoutState,paint): make BasicListUI aware of the
width of the rendered JList.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98385 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/javax/swing/JList.java')
| -rw-r--r-- | libjava/javax/swing/JList.java | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/libjava/javax/swing/JList.java b/libjava/javax/swing/JList.java index adb72892450..d9e9fee7f7c 100644 --- a/libjava/javax/swing/JList.java +++ b/libjava/javax/swing/JList.java @@ -1029,32 +1029,20 @@ public class JList extends JComponent implements Accessible, Scrollable */ public Dimension getPreferredScrollableViewportSize() { - int vis = getVisibleRowCount(); - int nrows = getModel() == null ? 0 : getModel().getSize(); - // FIXME: this is a somewhat arbitrary default, but.. ? - Dimension single = new Dimension(10, 10);; - Rectangle bounds = null; - if (vis > nrows) + Dimension retVal = getPreferredSize(); + if (getLayoutOrientation() == VERTICAL) { - if (fixedCellWidth != -1 && - fixedCellHeight != -1) + if (fixedCellHeight != -1) { - single = new Dimension(fixedCellWidth, fixedCellHeight); - } - else if (nrows != 0 && getUI() != null) - { - Rectangle tmp = getUI().getCellBounds(this, 0, 0); - if (tmp != null) - single = tmp.getSize(); - } - } - else if (getUI() != null) - { - return getUI().getCellBounds(this, 0, vis - 1).getSize(); + 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) } - - return new Dimension(single.width, single.height * vis); + return retVal; } /** @@ -1193,7 +1181,19 @@ public class JList extends JComponent implements Accessible, Scrollable */ public boolean getScrollableTracksViewportWidth() { - return false; + Component parent = getParent(); + boolean retVal = false; + if (parent instanceof JViewport) + { + JViewport viewport = (JViewport) parent; + Dimension pref = getPreferredSize(); + if (viewport.getSize().width > pref.width) + retVal = true; + if ((getLayoutOrientation() == HORIZONTAL_WRAP) + && (getVisibleRowCount() <= 0)) + retVal = true; + } + return retVal; } /** @@ -1206,7 +1206,19 @@ public class JList extends JComponent implements Accessible, Scrollable */ public boolean getScrollableTracksViewportHeight() { - return false; + Component parent = getParent(); + boolean retVal = false; + if (parent instanceof JViewport) + { + JViewport viewport = (JViewport) parent; + Dimension pref = getPreferredSize(); + if (viewport.getSize().height > pref.height) + retVal = true; + if ((getLayoutOrientation() == VERTICAL_WRAP) + && (getVisibleRowCount() <= 0)) + retVal = true; + } + return retVal; } public int getAnchorSelectionIndex() |

