Results 1 to 6 of 6

Thread: jtable

  1. #1
    mharsijamel is offline Member
    Join Date
    Aug 2011
    Posts
    60
    Rep Power
    0

    Default jtable

    i want to modify the value of a selected cell in jtable

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: jtable

    Moved from 'Advanced Java'

    1. In future, please post in an appropriate section of the forums.
    2. Don't post any beginner questions in 'Advanced Java'. There's a 'New to Java' section for those.

    db

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default Re: jtable

    Quote Originally Posted by mharsijamel View Post
    i want to modify the value of a selected cell in jtable
    Have you read the API for JTable (note: it's not jtable) and have you gone through the tutorial linked from the API?

    Recommended reading: How to ask questions the smart way


    db

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

    Default Re: jTable

    Java Code:
    table.setValueAt(...);
    Last edited by Fubarable; 09-11-2011 at 09:45 PM. Reason: post moved from locked duplicate thread to this one

  5. #5
    mharsijamel is offline Member
    Join Date
    Aug 2011
    Posts
    60
    Rep Power
    0

    Default Re: jtable

    Java Code:
    public void valueChanged(ListSelectionEvent e){
    if(jtable1.getValueAt(jtable1.getSelectedRow(), jtable1.getSelectedColumn())==true)
    jtable1.setValueAt(false, jtable1.getSelectedRow(), jtable1.getSelectedColumn());
    else
    jtable1.setValueAt(true, jtable1.getSelectedRow(), jtable1.getSelectedColumn());
    });
    i write this code but when executing it the value of selected cell change twice(for example:if cell=false then it change to true and return true)
    please help me

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

    Default Re: jtable

    I guess it is because two events are generated. One for the "deselection" of the previous row and one for the "selection" of the current row.

    You need to check e.getValueIsAdjusting() to determine when to execute your code.

Similar Threads

  1. JTable
    By BeeGee in forum Advanced Java
    Replies: 5
    Last Post: 04-28-2010, 05:29 PM
  2. Adding New JTable in JTable
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 01-27-2010, 08:27 AM
  3. JTable
    By hedonist in forum New To Java
    Replies: 3
    Last Post: 10-27-2009, 11:30 PM
  4. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  5. Help with JTable
    By fernando in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:57 AM

Posting Permissions

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