This week's giveaway is in the Threads forum.
We're giving away four copies of Java Concurrency Live Lessons and have Doug Schmidt on-line!
See this thread for details.
Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Disabling Mouse Drag or highlighting when mouse dragged on JTable  RSS feed

 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would you disable mouse drag or the selection of multiple rows when the mouse is dragged? I can select the whole list with a mouse drag and I don't really want to be able to do this. I have tried several things and nothing has really worked.
 
Hauke Ingmar Schmidt
Rancher
Posts: 436
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Selection is explained in the JTable tutorial.
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hauke Ingmar Schmidt wrote:Selection is explained in the JTable tutorial.


I like single selection but is their anyway to add ctrl+click to this selection?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Charles Sexton wrote:I like single selection but is their anyway to add ctrl+click to this selection?


Well, yeah, if you follow Hauke Ingmar's link you'll see an example right there. See the "Selection Mode" radio buttons? Multiple Interval Selection is the version which uses Ctrl-click.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Charles Sexton wrote:How would you disable mouse drag or the selection of multiple rows when the mouse is dragged? I can select the whole list with a mouse drag and I don't really want to be able to do this.


As for your original question: Why is it a problem that you can select rows that way? Surely you aren't accidentally dragging the mouse over the table and selecting rows you didn't mean to select?

I ask because it's often difficult to disable part of the normal functioning of a component. So if there isn't a serious need to answer this question, I would just leave it to work the way it works now.
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Charles Sexton wrote:How would you disable mouse drag or the selection of multiple rows when the mouse is dragged? I can select the whole list with a mouse drag and I don't really want to be able to do this.


As for your original question: Why is it a problem that you can select rows that way? Surely you aren't accidentally dragging the mouse over the table and selecting rows you didn't mean to select?

I ask because it's often difficult to disable part of the normal functioning of a component. So if there isn't a serious need to answer this question, I would just leave it to work the way it works now.


ok thank you
 
Bridget Kennedy
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Charles Sexton wrote:How would you disable mouse drag or the selection of multiple rows when the mouse is dragged? I can select the whole list with a mouse drag and I don't really want to be able to do this.


As for your original question: Why is it a problem that you can select rows that way? Surely you aren't accidentally dragging the mouse over the table and selecting rows you didn't mean to select?

I ask because it's often difficult to disable part of the normal functioning of a component. So if there isn't a serious need to answer this question, I would just leave it to work the way it works now.


Actually, I have a need to do this, too. In my case, I always want the drag gesture to be processed as a part of a drag-and-drop sequence. I do want the user to have the ability to select multiple rows through control- or shift-click, but mouse drag is the prelude to drag-and-drop. As it is, sometimes the drag gesture is interpreted as a multi-row select prior to handling the drag gesture event. It seems you have a choice of either single-select, or ambiguous drag-and-drop processing.
 
Bridget Kennedy
Ranch Hand
Posts: 86
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alert teammate found solution here: https://community.oracle.com/thread/1351319

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!