aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Jtable uneditable cells in a specific table column (regardless of row) 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 "Jtable uneditable cells in a specific table column (regardless of row)" Watch "Jtable uneditable cells in a specific table column (regardless of row)" New topic
Author

Jtable uneditable cells in a specific table column (regardless of row)

borj bersas
Greenhorn

Joined: Apr 19, 2010
Posts: 20
scenario:

4 columns and lots of rows

column 1 and 2 cells are editable
while column 3 and 4 cells are not editable.

is this possible? if so, any help would be appreciated ^^

btw, i also tried overriding the isCellEditable(int row,int column) but the output is all cells in every column are not editable,
i only need the column 3 and 4 to be uneditable while the others are still editable.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2203
    
    7
btw, i also tried overriding the isCellEditable(int row,int column) but the output is all cells in every column are not editable,


Then you code is wrong. You need to add an "if statement" to control which columns are editable and which ones are not.
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3168
    
  47

"borj bn", please check your private messages regarding an important administrative matter.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> i also tried overriding the isCellEditable(int row,int column) but the output is all cells in every column are not editable,

in isCellEditable(int row,int column), you only need to
return column < 2;//0-based
borj bersas
Greenhorn

Joined: Apr 19, 2010
Posts: 20
here is my code,


still all of the cells are affected, can anyone of you guys reconstruct my code? tnx in advance
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
just by creating another 'mainTable', from the original's model,
doesn't do anything to the original 'mainTable', which is presumably
the one showing on the screen, and therefore all editable

search this forum (or google) isCellEditable and you'll find numerous examples
that you can compile/run and test to see that they do work, then modify your code accordingly
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3168
    
  47

borj, please UseCodeTags. I've added code tags for you.
borj bersas
Greenhorn

Joined: Apr 19, 2010
Posts: 20
oops! sorry admin hehe,
btw, i solved my problem hehe, tnx for your effort guys

 
Consider Paul's rocket mass heater.
 
subject: Jtable uneditable cells in a specific table column (regardless of row)