protected boolean clicksInCheckBox(MouseEvent e) { int index = _list.locationToIndex(e.getPoint()); Rectangle bounds = _list.getCellBounds(index, index); if (bounds != null) { if (_list.getComponentOrientation().isLeftToRight()) { return e.getX() < bounds.x + hotspot; } else { return e.getX() > bounds.x + bounds.width - hotspot; } } else { return false; } }
public void mousePressed(MouseEvent e) { if (e.isConsumed()) { return; } if (!_list.isCheckBoxEnabled()) { return; } boolean clickInBox = clicksInCheckBox(e); if (!_list.isClickInCheckBoxOnly() || clickInBox) { int index = _list.locationToIndex(e.getPoint()); toggleSelection(index); if (clickInBox) { e.consume(); } } }