Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Enabling/Disabling Rows in JTable  RSS feed

 
pothineni rajesh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Small Code snippet for enabling/disabling rows in a Table
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might find this an interesting read.
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by disabling? Making the row not selectable, or making each cell of the row not editable?

The latter is quite easy: check TableModel.isCellEditable.
 
pothineni rajesh
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:What do you mean by disabling? Making the row not selectable, or making each cell of the row not editable?

The latter is quite easy: check TableModel.isCellEditable.


Hi,

I want to make the row not selectable based on some parameters not the cell.
Thank you in advance
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JTable.setSelectionModel in combination with the ListSelectionModel interface. With the addSelectionInterval and insertSelectionInterval methods you determine what rows / columns are actually selected.

Perhaps the easiest way is to wrap the default selection model:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!