/[classpath]/classpath/javax/swing/plaf/basic/BasicListUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicListUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by rabbit78, Fri Jun 17 10:12:29 2005 UTC revision 1.20 by abalkiss, Thu Jun 30 18:16:58 2005 UTC
# Line 200  public class BasicListUI extends ListUI Line 200  public class BasicListUI extends ListUI
200        if (evt.getKeyCode() == KeyEvent.VK_DOWN)        if (evt.getKeyCode() == KeyEvent.VK_DOWN)
201          {          {
202            int lead = BasicListUI.this.list.getLeadSelectionIndex();            int lead = BasicListUI.this.list.getLeadSelectionIndex();
203              int max = BasicListUI.this.list.getModel().getSize() - 1;
204            if (!evt.isShiftDown())            if (!evt.isShiftDown())
205              {              {
206                BasicListUI.this.list.clearSelection();                BasicListUI.this.list.clearSelection();
207                BasicListUI.this.list.setSelectedIndex(lead+1);                BasicListUI.this.list.setSelectedIndex(Math.min(lead+1,max));
208              }              }
209            else            else
210              {              {
211                BasicListUI.this.list.getSelectionModel().setLeadSelectionIndex(lead+1);                BasicListUI.this.list.getSelectionModel().
212                    setLeadSelectionIndex(Math.min(lead+1,max));
213              }              }
214          }          }
215        else if (evt.getKeyCode() == KeyEvent.VK_UP)        else if (evt.getKeyCode() == KeyEvent.VK_UP)
# Line 220  public class BasicListUI extends ListUI Line 222  public class BasicListUI extends ListUI
222              }              }
223            else            else
224              {              {
225                BasicListUI.this.list.getSelectionModel().setLeadSelectionIndex(Math.max(lead-1,0));                BasicListUI.this.list.getSelectionModel().
226                    setLeadSelectionIndex(Math.max(lead-1,0));
227              }              }
228          }          }
229      }      }
# Line 244  public class BasicListUI extends ListUI Line 247  public class BasicListUI extends ListUI
247        int index = BasicListUI.this.locationToIndex(list, click);        int index = BasicListUI.this.locationToIndex(list, click);
248        if (index == -1)        if (index == -1)
249          return;          return;
250        boolean controlPressed = event.isControlDown();        if (event.isControlDown())
       if (controlPressed)  
251          {          {
252            if (BasicListUI.this.list.getSelectionMode() == ListSelectionModel.SINGLE_SELECTION)            if (BasicListUI.this.list.getSelectionMode() ==
253                  ListSelectionModel.SINGLE_SELECTION)
254              BasicListUI.this.list.setSelectedIndex(index);              BasicListUI.this.list.setSelectedIndex(index);
255            else if (BasicListUI.this.list.isSelectedIndex(index))            else if (BasicListUI.this.list.isSelectedIndex(index))
256              BasicListUI.this.list.removeSelectionInterval(index,index);              BasicListUI.this.list.removeSelectionInterval(index,index);
257            else            else
258              BasicListUI.this.list.addSelectionInterval(index,index);              BasicListUI.this.list.addSelectionInterval(index,index);
259          }          }
260          else if (event.isShiftDown())
261            {
262              if (BasicListUI.this.list.getSelectionMode() ==
263                  ListSelectionModel.SINGLE_SELECTION)
264                BasicListUI.this.list.setSelectedIndex(index);
265              else if (BasicListUI.this.list.getSelectionMode() ==
266                       ListSelectionModel.SINGLE_INTERVAL_SELECTION)
267                // COMPAT: the IBM VM is compatible with the following line of code.
268                // However, compliance with Sun's VM would correspond to replacing
269                // getAnchorSelectionIndex() with getLeadSelectionIndex().This is
270                // both unnatural and contradictory to the way they handle other
271                // similar UI interactions.
272                BasicListUI.this.list.setSelectionInterval
273                  (BasicListUI.this.list.getAnchorSelectionIndex(), index);
274              else
275                // COMPAT: both Sun and IBM are compatible instead with:
276                // BasicListUI.this.list.setSelectionInterval
277                //     (BasicListUI.this.list.getLeadSelectionIndex(),index);
278                // Note that for IBM this is contradictory to what they did in
279                // the above situation for SINGLE_INTERVAL_SELECTION.  
280                // The most natural thing to do is the following:
281                BasicListUI.this.list.getSelectionModel().
282                  setLeadSelectionIndex(index);
283            }
284        else        else
285          BasicListUI.this.list.setSelectedIndex(index);          BasicListUI.this.list.setSelectedIndex(index);
286      }      }

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26