aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Enabling/Disabling  Rows  in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Enabling/Disabling  Rows  in JTable" Watch "Enabling/Disabling  Rows  in JTable" New topic
Author

Enabling/Disabling Rows in JTable

pothineni rajesh
Greenhorn

Joined: Dec 17, 2008
Posts: 18
Small Code snippet for enabling/disabling rows in a Table
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

You might find this an interesting read.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
pothineni rajesh
Greenhorn

Joined: Dec 17, 2008
Posts: 18
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

Joined: Oct 27, 2005
Posts: 19722
    
  20

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:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enabling/Disabling Rows in JTable