Results 1 to 6 of 6
  1. #1
    Subhasri is offline Member
    Join Date
    Sep 2011
    Posts
    15
    Rep Power
    0

    Default How to disable(Unedit) a cell in JTable?

    I am developing a application in NetBeans. In this application, I am using JTable.

    Based on a value given in a JTable Cell, another column in that row should be disabled(i.e that cell could not be editable).

    For example, if i give "Cash" in the 2nd Column of a row,then the 3rd column of that row should be disabled.


    How to Solve this problem?


    Thanks in advance.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: How to disable(Unedit) a cell in JTable?

    The TableModel interface has a isCellEditable() method. You could override that for your table model to do the right thing: ie to look in column 2 and return a value appropriate to what it finds.

  3. #3
    Subhasri is offline Member
    Join Date
    Sep 2011
    Posts
    15
    Rep Power
    0

    Default Re: How to disable(Unedit) a cell in JTable?

    Pls give me some sample code to achieve this..

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: How to disable(Unedit) a cell in JTable?

    This is a forum, not a code mill. Read the API for JTable and follow the link to the tutorial on How to Use Tables where you will find some code samples. Post your best effort, in the form of an SSCCE and ask a specific question if you still have a problem.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Subhasri is offline Member
    Join Date
    Sep 2011
    Posts
    15
    Rep Power
    0

    Default Re: How to disable(Unedit) a cell in JTable?

    I know this is a forum not a code mill. I referred all those things but not found solution. So only posted in forum. if u could not, then dont reply..

  6. #6
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,236
    Rep Power
    7

    Default Re: How to disable(Unedit) a cell in JTable?

    Darryl DID post a solution. The tutorial has a working example that shows how to override the isCellEditable() method.

    If you don't like that solution you can always search this or any other forum. You've been given the method name to use. So read the API to understand what the method is used for and then search for code examples that use that method.

Similar Threads

  1. Disable a checkbox in jtable
    By pink123 in forum AWT / Swing
    Replies: 8
    Last Post: 03-24-2011, 06:29 PM
  2. JTable disable drag and drop row
    By NextEpisode1 in forum AWT / Swing
    Replies: 1
    Last Post: 02-10-2011, 06:46 PM
  3. JTable: Disable sorting on one column
    By b.newworld@gmail.com in forum AWT / Swing
    Replies: 1
    Last Post: 09-16-2010, 12:43 AM
  4. Setting jTable cell?
    By greatmajestics in forum New To Java
    Replies: 5
    Last Post: 04-22-2010, 05:33 PM
  5. jtable cell background
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 02-22-2010, 04:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •