Пример #1
0
    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;
      }
    }
Пример #2
0
    public void mousePressed(MouseEvent e) {
      if (e.isConsumed()) {
        return;
      }

      if (!_list.isCheckBoxEnabled()) {
        return;
      }

      if (!_list.isClickInCheckBoxOnly() || clicksInCheckBox(e)) {
        int index = _list.locationToIndex(e.getPoint());
        toggleSelection(index);
        e.consume();
      }
    }