Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable: How to turn off a cell from being dragged  RSS feed

 
Alfonso Sanz
Ranch Hand
Posts: 69
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Sorry for my dumb question , but I am currently blocked.
I have a question about JTable:

My JTable is composed by rows that I drag from the JTable and drop on a JFrame, once a row is dragged/dropped I want to avoid this row from being dragged again, but I have no idea about what to do.

Any clue?

Thanks in advance.
 
Rob Camick
Ranch Hand
Posts: 2800
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add another column to your TableModel with a Boolean value to indicate if the row has been dragged.

Then when you do the drag you set the value to Boolean.TRUE. Then in your drag logic you check this variable.

You can prevent this column from being visible in the table by using:

table.removeColumn( table.getColulmn(...) );
 
Alfonso Sanz
Ranch Hand
Posts: 69
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot. Great idea!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!