my dog learned polymorphism*
The moose likes Swing / AWT / SWT and the fly likes JTable question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable question" Watch "JTable question" New topic
Author

JTable question

igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
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

Joined: Jan 06, 2005
Posts: 140
You may try to check columnIndex == 1...

Hope that helps,


Lionel Badiou
CodeFutures Software
igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
Um, it doesn't work, where do I put columnIndex == -1; thanks.
igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
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;
}
};
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable question