< prev index next >

src/java.desktop/share/classes/javax/swing/plaf/basic/BasicListUI.java

Print this page

        

*** 2132,2141 **** --- 2132,2142 ---- ListSelectionModel lsm = list.getSelectionModel(); int lead = adjustIndex(lsm.getLeadSelectionIndex(), list); Rectangle leadRect = (lead==-1) ? new Rectangle() : list.getCellBounds(lead, lead); + if (leadRect != null) { if (list.getLayoutOrientation() == JList.VERTICAL_WRAP && list.getVisibleRowCount() <= 0) { if (!list.getComponentOrientation().isLeftToRight()) { direction = -direction; }
*** 2145,2177 **** // left visRect.x = leadRect.x + leadRect.width - visRect.width; Point p = new Point(visRect.x - 1, leadRect.y); index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); ! if (visRect.intersects(cellBounds)) { p.x = cellBounds.x - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } // this is necessary for right-to-left orientation only ! if (cellBounds.y != leadRect.y) { p.x = cellBounds.x + cellBounds.width; index = list.locationToIndex(p); } } else { // right visRect.x = leadRect.x; Point p = new Point(visRect.x + visRect.width, leadRect.y); index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); ! if (visRect.intersects(cellBounds)) { p.x = cellBounds.x + cellBounds.width; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } ! if (cellBounds.y != leadRect.y) { p.x = cellBounds.x - 1; index = list.locationToIndex(p); } } } --- 2146,2178 ---- // left visRect.x = leadRect.x + leadRect.width - visRect.width; Point p = new Point(visRect.x - 1, leadRect.y); index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); ! if (cellBounds != null && visRect.intersects(cellBounds)) { p.x = cellBounds.x - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } // this is necessary for right-to-left orientation only ! if (cellBounds != null && cellBounds.y != leadRect.y) { p.x = cellBounds.x + cellBounds.width; index = list.locationToIndex(p); } } else { // right visRect.x = leadRect.x; Point p = new Point(visRect.x + visRect.width, leadRect.y); index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); ! if (cellBounds != null && visRect.intersects(cellBounds)) { p.x = cellBounds.x + cellBounds.width; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } ! if (cellBounds != null && cellBounds.y != leadRect.y) { p.x = cellBounds.x - 1; index = list.locationToIndex(p); } } }
*** 2188,2205 **** p.y = visRect.y; index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); // go one cell down if first visible cell doesn't fit // into adjasted visible rectangle ! if (cellBounds.y < visRect.y) { p.y = cellBounds.y + cellBounds.height; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } // if index isn't less then lead // try to go to cell previous to lead ! if (cellBounds.y >= leadRect.y) { p.y = leadRect.y - 1; index = list.locationToIndex(p); } } } --- 2189,2206 ---- p.y = visRect.y; index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); // go one cell down if first visible cell doesn't fit // into adjasted visible rectangle ! if (cellBounds != null && cellBounds.y < visRect.y) { p.y = cellBounds.y + cellBounds.height; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } // if index isn't less then lead // try to go to cell previous to lead ! if (cellBounds != null && cellBounds.y >= leadRect.y) { p.y = leadRect.y - 1; index = list.locationToIndex(p); } } }
*** 2210,2221 **** visRect.y + visRect.height - 1); index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); // go up one cell if last visible cell doesn't fit // into visible rectangle ! if (cellBounds.y + cellBounds.height > ! visRect.y + visRect.height) { p.y = cellBounds.y - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); index = Math.max(index, lead); } --- 2211,2224 ---- visRect.y + visRect.height - 1); index = list.locationToIndex(p); Rectangle cellBounds = list.getCellBounds(index, index); // go up one cell if last visible cell doesn't fit // into visible rectangle ! if (cellBounds != null && ! cellBounds.y + cellBounds.height > ! visRect.y + visRect.height) ! { p.y = cellBounds.y - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); index = Math.max(index, lead); }
*** 2227,2251 **** p.y = visRect.y + visRect.height - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); // go one cell up if last visible cell doesn't fit // into adjasted visible rectangle ! if (cellBounds.y + cellBounds.height > ! visRect.y + visRect.height) { p.y = cellBounds.y - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } // if index isn't greater then lead // try to go to cell next after lead ! if (cellBounds.y <= leadRect.y) { p.y = leadRect.y + leadRect.height; index = list.locationToIndex(p); } } } } return index; } private void changeSelection(JList<?> list, int type, int index, int direction) { --- 2230,2257 ---- p.y = visRect.y + visRect.height - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); // go one cell up if last visible cell doesn't fit // into adjasted visible rectangle ! if (cellBounds != null && ! cellBounds.y + cellBounds.height > ! visRect.y + visRect.height) ! { p.y = cellBounds.y - 1; index = list.locationToIndex(p); cellBounds = list.getCellBounds(index, index); } // if index isn't greater then lead // try to go to cell next after lead ! if (cellBounds != null && cellBounds.y <= leadRect.y) { p.y = leadRect.y + leadRect.height; index = list.locationToIndex(p); } } } } + } return index; } private void changeSelection(JList<?> list, int type, int index, int direction) {
*** 2308,2344 **** cellBounds.x + cellBounds.width - visRect.width); int startIndex = list.locationToIndex(new Point(x, cellBounds.y)); Rectangle startRect = list.getCellBounds(startIndex, startIndex); ! if (startRect.x < x && startRect.x < cellBounds.x) { startRect.x += startRect.width; startIndex = list.locationToIndex(startRect.getLocation()); startRect = list.getCellBounds(startIndex, startIndex); } ! cellBounds = startRect; } cellBounds.width = visRect.width; } else { if (direction > 0) { // left for right-to-left int x = cellBounds.x + visRect.width; int rightIndex = list.locationToIndex(new Point(x, cellBounds.y)); Rectangle rightRect = list.getCellBounds(rightIndex, rightIndex); if (rightRect.x + rightRect.width > x && rightRect.x > cellBounds.x) { rightRect.width = 0; } cellBounds.x = Math.max(0, rightRect.x + rightRect.width - visRect.width); cellBounds.width = visRect.width; } else { cellBounds.x += Math.max(0, cellBounds.width - visRect.width); // adjust width to fit into visible rectangle cellBounds.width = Math.min(cellBounds.width, --- 2314,2355 ---- cellBounds.x + cellBounds.width - visRect.width); int startIndex = list.locationToIndex(new Point(x, cellBounds.y)); Rectangle startRect = list.getCellBounds(startIndex, startIndex); ! if (startRect != null && ! startRect.x < x && startRect.x < cellBounds.x) { startRect.x += startRect.width; startIndex = list.locationToIndex(startRect.getLocation()); startRect = list.getCellBounds(startIndex, startIndex); } ! cellBounds = startRect != null ? startRect : null; } + if (cellBounds != null) { cellBounds.width = visRect.width; } + } else { if (direction > 0) { // left for right-to-left int x = cellBounds.x + visRect.width; int rightIndex = list.locationToIndex(new Point(x, cellBounds.y)); Rectangle rightRect = list.getCellBounds(rightIndex, rightIndex); + if (rightRect != null) { if (rightRect.x + rightRect.width > x && rightRect.x > cellBounds.x) { rightRect.width = 0; } cellBounds.x = Math.max(0, rightRect.x + rightRect.width - visRect.width); cellBounds.width = visRect.width; } + } else { cellBounds.x += Math.max(0, cellBounds.width - visRect.width); // adjust width to fit into visible rectangle cellBounds.width = Math.min(cellBounds.width,
*** 2357,2376 **** cellBounds.y + cellBounds.height - visRect.height); int startIndex = list.locationToIndex(new Point(cellBounds.x, y)); Rectangle startRect = list.getCellBounds(startIndex, startIndex); ! if (startRect.y < y && startRect.y < cellBounds.y) { startRect.y += startRect.height; startIndex = list.locationToIndex(startRect.getLocation()); startRect = list.getCellBounds(startIndex, startIndex); } ! cellBounds = startRect; cellBounds.height = visRect.height; } else { // adjust height to fit into visible rectangle cellBounds.height = Math.min(cellBounds.height, visRect.height); } } --- 2368,2390 ---- cellBounds.y + cellBounds.height - visRect.height); int startIndex = list.locationToIndex(new Point(cellBounds.x, y)); Rectangle startRect = list.getCellBounds(startIndex, startIndex); ! if (startRect != null && ! startRect.y < y && startRect.y < cellBounds.y) { startRect.y += startRect.height; startIndex = list.locationToIndex(startRect.getLocation()); startRect = list.getCellBounds(startIndex, startIndex); } ! cellBounds = startRect != null ? startRect : null; ! if (cellBounds != null) { cellBounds.height = visRect.height; } + } else { // adjust height to fit into visible rectangle cellBounds.height = Math.min(cellBounds.height, visRect.height); } }
< prev index next >