Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable question

 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I'm having this problem with JTables.

I created one by using the following code:

JTable table = new JTable(4,2) {
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
};

But, the thing is, I only want the 1st column of every row to be uneditable. It is supposed to be like a key/value pair. How can I make only the second column of each of my rows to be editable. Thank you.
 
Lionel Badiou
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may try to check columnIndex == 1...

Hope that helps,
 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um, it doesn't work, where do I put columnIndex == -1; thanks.
 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I figured it out, this is the code I used instead:

JTable table = new JTable(4,2) {
public boolean isCellEditable(int rowIndex, int columnIndex) {

boolean returnValue = false;

if (columnIndex == 1) {
return true;
}//end if

return returnValue;
}
};
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic