Setting the Activation Click Count for a Table Cell Editor in a JTable Component

By default, a table cell editor is activated with a double-click. The activation behavior is controlled by the renderer, not by a table property. To change this, override the isCellEditable() method of the editor. See Creating a Custom Table Cell Editor in a JTable Component for more information about table cell editors.
public class MyTableCellEditor extends AbstractCellEditor implements TableCellEditor { // See Creating a Custom Table Cell Editor in a JTable Component // for other methods that need to be implemented. public boolean isCellEditable(EventObject evt) { if (evt instanceof MouseEvent) { int clickCount; // For single-click activation clickCount = 1; // For double-click activation clickCount = 2; // For triple-click activation clickCount = 3; return ((MouseEvent)evt).getClickCount() >= clickCount; } return true; } }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.