private void selectClicked(MouseEvent e,boolean onlyOutside){
  int index=list.locationToIndex(e.getPoint());
  Rectangle bounds=list.getCellBounds(index,index);
  if (bounds != null && bounds.contains(e.getPoint())) {
    if (!onlyOutside) {
      if (list.isSelectedIndex(index)) {
        list.addSelectionInterval(index,index);
      }
 else {
        list.setSelectedIndex(index);
      }
    }
  }
 else {
    list.clearSelection();
  }
}

private void selectClicked ( MouseEvent e , boolean onlyOutside ) { int index = list . locationToIndex ( e . getPoint ( ) ) ; Rectangle bounds = list . getCellBounds ( index , index ) ; if ( bounds != null && bounds . contains ( e . getPoint ( ) ) ) { if ( ! onlyOutside ) { if ( list . isSelectedIndex ( index ) ) { list . addSelectionInterval ( index , index ) ; } else { list . setSelectedIndex ( index ) ; } } } else { list . clearSelection ( ) ; } }
adds selection of the clicked element , or removes selection if no element was clicked .
