Results 1 to 3 of 3
  1. #1
    LenteraSoft is offline Member
    Join Date
    May 2014
    Posts
    4
    Rep Power
    0

    Default how to compare two jtable and set value from one jtable to the other one?

    Good Morning all,
    I have a problem here. I need to compare two jtable and set the value from one jtabel to the other jtable.

    jtable one consist of:
    Unit ID Unit Name Access
    ABC, Inc ABC Incorporate (checkbox) value = uncheck
    CDE, Inc CDE Incorporate (Checkbox) value = uncheck


    jtable two consist of:
    Unit ID Access
    ABC, Inc ABC Incorporate (checkbox) value = checked
    CDE, Inc CDE Incorporate (Checkbox) value = checked


    if comparing jtable one an jtable two has the same Unit ID then colum Access from jtable two value is set to jtable one become check based on jtable two.

    I did the code but did not work:
    for (i = 0, jTable1.getrowcount(), i++) {
    for (j = 0, jTable1.getrowcount(), j++) {
    if (jTable1.getvalueAt(i,0) == jTable2.getvalueat(j,0)) {
    jTable1.setvalueat(true,i,2)
    }
    }
    }

    above code i try did not make any changes. please help. thank you very much.


    Regards,
    LS.

  2. #2
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Posts
    447
    Rep Power
    1

    Default Re: how to compare two jtable and set value from one jtable to the other one?

    You compared strings with == instead with equals. Look that up if you don't understand why that is wrong.

  3. #3
    LenteraSoft is offline Member
    Join Date
    May 2014
    Posts
    4
    Rep Power
    0

    Default Re: how to compare two jtable and set value from one jtable to the other one?

    afte try, its working. tq very much pal...

Similar Threads

  1. Jtable inside Jtable
    By anchitanc in forum AWT / Swing
    Replies: 5
    Last Post: 05-26-2012, 08:10 PM
  2. Replies: 4
    Last Post: 04-02-2012, 07:57 PM
  3. Adding New JTable in JTable
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 01-27-2010, 08:27 AM
  4. Regarding JTable
    By adeeb in forum SWT / JFace
    Replies: 0
    Last Post: 06-18-2008, 06:13 PM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 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
  •