1032 |
*/ |
*/ |
1033 |
public Dimension getPreferredScrollableViewportSize() |
public Dimension getPreferredScrollableViewportSize() |
1034 |
{ |
{ |
1035 |
|
//If the layout orientation is not VERTICAL, then this will |
1036 |
|
//return the value from getPreferredSize. The current ListUI is |
1037 |
|
//expected to override getPreferredSize to return an appropriate value. |
1038 |
|
if (getLayoutOrientation() != VERTICAL) |
1039 |
|
return getPreferredSize(); |
1040 |
|
|
1041 |
|
if (fixedCellHeight != -1 && fixedCellWidth != -1) |
1042 |
|
return new Dimension(fixedCellWidth, getModel().getSize() * |
1043 |
|
fixedCellHeight); |
1044 |
|
|
1045 |
Dimension retVal = getPreferredSize(); |
int prefWidth, prefHeight; |
1046 |
if (getLayoutOrientation() == VERTICAL) |
if (fixedCellWidth != -1) |
1047 |
|
prefWidth = fixedCellWidth; |
1048 |
|
else |
1049 |
{ |
{ |
1050 |
if (fixedCellHeight != -1) |
prefWidth = 0; |
1051 |
{ |
int size = getModel().getSize(); |
1052 |
if (fixedCellWidth != -1) |
for (int i = 0; i < size; i++) |
1053 |
{ |
if (getCellBounds(i, i).width > prefWidth) |
1054 |
int size = getModel().getSize(); |
prefWidth = getCellBounds(i, i).width; |
|
retVal = new Dimension(fixedCellWidth, size * fixedCellHeight); |
|
|
} // TODO: add else clause (preferredSize is ok for now) |
|
|
} // TODO: add else clause (preferredSize is ok for now) |
|
1055 |
} |
} |
1056 |
return retVal; |
|
1057 |
|
if (getModel().getSize() == 0 && fixedCellWidth == -1) |
1058 |
|
return new Dimension(256, 16 * getVisibleRowCount()); |
1059 |
|
else if (getModel().getSize() == 0) |
1060 |
|
return new Dimension (fixedCellWidth, 16 * getVisibleRowCount()); |
1061 |
|
|
1062 |
|
if (fixedCellHeight != -1) |
1063 |
|
prefHeight = fixedCellHeight; |
1064 |
|
else |
1065 |
|
{ |
1066 |
|
prefHeight = getVisibleRowCount() * getCellBounds |
1067 |
|
(getFirstVisibleIndex(), getFirstVisibleIndex()).height; |
1068 |
|
} |
1069 |
|
return new Dimension (prefWidth, prefHeight); |
1070 |
} |
} |
1071 |
|
|
1072 |
/** |
/** |