right,离开原选中行一次,进入新选中行一次

解决方案 »

  1.   

    是这样的吗?十分感谢!
    不过我怎么获得所选项呢?ListSelectionListener 接口里只有 valueChanged一个方法呀。
    要是这样  :
    class LSL
          implements ListSelectionListener {
        public void valueChanged(ListSelectionEvent e) {
             String selected=(String)((JList)e.getSource()).getSelectedValue();
                                   //使用selected
           }
      }
    可以获得所选项,但仍是执行了两次呀。
    难道要注册MouseListener
     吗(使用 int locationToIndex(Point location) ) ?而且好像不能取消选择,这样每次发生选项改变时都会执行两次,这个方法还怎么用呢?