Here you can find the source of clickedInSelection(MouseEvent e)
Parameter | Description |
---|---|
e | a parameter |
public static boolean clickedInSelection(MouseEvent e)
//package com.java2s; /*/*ww w. j a v a 2s . c o m*/ This file is part of Subclient. Subclient is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Subclient is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Subclient. If not, see <http://www.gnu.org/licenses/>. Copyright 2012, 2013 Alejandro Celaya Alastru? */ import java.awt.event.MouseEvent; import javax.swing.JTable; public class Main { /** * Tests if one clicked on already selected rows. * @param e * @return True if one clicked on already selected rows. False otherwise. */ public static boolean clickedInSelection(MouseEvent e) { // If invoker is not a table, return false if (!(e.getSource() instanceof JTable)) return false; // If no rows are selected, return false JTable invoker = (JTable) e.getSource(); if (invoker.getSelectedRows().length == 0) return false; // Get clicked row int clickedRow = invoker.rowAtPoint(e.getPoint()); // Get already selected rows for (int selectedRow : invoker.getSelectedRows()) { if (selectedRow == clickedRow) return true; } return false; } }