| Author |
enabling and disabling single cell in JTable
|
Mahesh Kedari
Ranch Hand
Joined: Nov 28, 2009
Posts: 109
|
|
Hi all,
Is it possible to control enabling and disabling of table at cell level?
I have checked this post, but its partially helpful.
Requirement :
I have a table with 7 columns. If value of 2nd column in specific row is null then all other cells in that rows should be disabled.
But it should not disable other rows in which 2nd column contains valid data.
Could anyone please help me ?
|
Regards,
Mahesh Kedari - Fidus Technologies Ltd.
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
Mahesh Kedari wrote:Hi all,
Is it possible to control enabling and disabling of table at cell level?
I have checked this post, but its partially helpful.
How is it "partially" helpful as it has the key to your problem. Perhaps you should post a small compilable and runnable program that has no outside dependencies (no need for database or files), that illustrates your problem,and that shows how overriding the isCellEditable method doesn't work for you. This type of program is called an SSCCE. Please see this link for more instructions on how to create this: SSCCE link
|
 |
Mahesh Kedari
Ranch Hand
Joined: Nov 28, 2009
Posts: 109
|
|
Thanks pete for your reply.
Below is the runnable example of my code.
I am adding new row to table if editing row is last row of the table. Here user must select the date first before editing anything else in that row. So i want to disable other cells in that row.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
TableModel.isCellEditable takes both a row and column. That allows you to return a value dynamically based on the exact cell. Overriding DefaultTableModel is the easiest:
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Mahesh Kedari
Ranch Hand
Joined: Nov 28, 2009
Posts: 109
|
|
Thanks alot Rob for help...!!
Its working fine.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
You're welcome.
|
 |
 |
|
|
subject: enabling and disabling single cell in JTable
|
|
|