< prev index next >

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

Print this page




2209                         index = list.locationToIndex(p);
2210                         cellBounds = list.getCellBounds(index, index);
2211                         index = Math.max(index, lead);
2212                     }
2213 
2214                     if (lead >= index) {
2215                         // if lead is the last completely visible index
2216                         // (or below it) adjust the visible rect down
2217                         visRect.y = leadRect.y;
2218                         p.y = visRect.y + visRect.height - 1;
2219                         index = list.locationToIndex(p);
2220                         cellBounds = list.getCellBounds(index, index);
2221                         // go one cell up if last visible cell doesn't fit
2222                         // into adjasted visible rectangle
2223                         if (cellBounds.y + cellBounds.height >
2224                             visRect.y + visRect.height) {
2225                             p.y = cellBounds.y - 1;
2226                             index = list.locationToIndex(p);
2227                             cellBounds = list.getCellBounds(index, index);
2228                         }
2229                         // if index isn't greater then lead
2230                         // try to go to cell next after lead
2231                         if (cellBounds.y <= leadRect.y) {
2232                             p.y = leadRect.y + leadRect.height;
2233                             index = list.locationToIndex(p);
2234                         }
2235                     }
2236                 }
2237             }
2238             return index;
2239         }
2240 
2241         private void changeSelection(JList<?> list, int type,
2242                                      int index, int direction) {
2243             if (index >= 0 && index < list.getModel().getSize()) {
2244                 ListSelectionModel lsm = list.getSelectionModel();
2245 
2246                 // CHANGE_LEAD is only valid with multiple interval selection
2247                 if (type == CHANGE_LEAD &&
2248                         list.getSelectionMode()
2249                             != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {




2209                         index = list.locationToIndex(p);
2210                         cellBounds = list.getCellBounds(index, index);
2211                         index = Math.max(index, lead);
2212                     }
2213 
2214                     if (lead >= index) {
2215                         // if lead is the last completely visible index
2216                         // (or below it) adjust the visible rect down
2217                         visRect.y = leadRect.y;
2218                         p.y = visRect.y + visRect.height - 1;
2219                         index = list.locationToIndex(p);
2220                         cellBounds = list.getCellBounds(index, index);
2221                         // go one cell up if last visible cell doesn't fit
2222                         // into adjasted visible rectangle
2223                         if (cellBounds.y + cellBounds.height >
2224                             visRect.y + visRect.height) {
2225                             p.y = cellBounds.y - 1;
2226                             index = list.locationToIndex(p);
2227                             cellBounds = list.getCellBounds(index, index);
2228                         }
2229                         // if index isn't greater than lead
2230                         // try to go to cell next after lead
2231                         if (cellBounds.y <= leadRect.y) {
2232                             p.y = leadRect.y + leadRect.height;
2233                             index = list.locationToIndex(p);
2234                         }
2235                     }
2236                 }
2237             }
2238             return index;
2239         }
2240 
2241         private void changeSelection(JList<?> list, int type,
2242                                      int index, int direction) {
2243             if (index >= 0 && index < list.getModel().getSize()) {
2244                 ListSelectionModel lsm = list.getSelectionModel();
2245 
2246                 // CHANGE_LEAD is only valid with multiple interval selection
2247                 if (type == CHANGE_LEAD &&
2248                         list.getSelectionMode()
2249                             != ListSelectionModel.MULTIPLE_INTERVAL_SELECTION) {


< prev index next >