This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
borj bersas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2600
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4511
271
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"borj bn", please check your private messages regarding an important administrative matter.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 4511
271
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
borj, please UseCodeTags. I've added code tags for you.
 
borj bersas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops! sorry admin hehe,
btw, i solved my problem hehe, tnx for your effort guys

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic