• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable using CTRL + Click for multiple row selection

 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to do single selection, but I would like to do multiple row selection only by using CTRL + click without the option of dragging the mouse to select rows. So the user would have to hit ctrl + click each time to highlight additional rows. What would I need to do in order to do this?
 
Rob Spoor
Sheriff
Posts: 20820
68
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By default that's already enabled.

There are two important settings for selection:
- the selection mode (single selection, single interval, multiple intervals). You can change this with method setSelectionMode.
- whether or not separate columns can be selected, or only rows. You can change this with method setColumnSelectionAllowed

The default is multiple intervals and only row selection.
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:By default that's already enabled.

There are two important settings for selection:
- the selection mode (single selection, single interval, multiple intervals). You can change this with method setSelectionMode.
- whether or not separate columns can be selected, or only rows. You can change this with method setColumnSelectionAllowed

The default is multiple intervals and only row selection.


Would I have to do a mouse event listener in order to disable the mouse drag? Whenever you drag in either Multiple_Intervale or Single_Interval it highlights more than one row. Would mouse event listener be the best way to remove this?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!