• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

enabling and disabling single cell in JTable

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 22849
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Mahesh Kedari
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot Rob for help...!!
Its working fine.
 
Rob Spoor
Sheriff
Posts: 22849
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
reply
    Bookmark Topic Watch Topic
  • New Topic