Results 1 to 6 of 6

Thread: Fill JTable with several values

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    Fill JTable with several values

    Hello,
    I try to fill JTable with the result of several sql queries example the result of my first query in the first two columns of JTable, the result of 2nd application in the 3rd column so on. Unfortunately I have not found a solution yet. do you have any ides to solve this kind of problem or program. Thank you to those who find the time to help me.
    Last edited by Logan 2; 19-01-2010 at 02:26 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Fill JTable with several values

    Hello,
    Unfortunately I have not found a solution yet. do you have any ides to solve this kind of problem or program.
    We can do this in two steps: first we fill the table with the first result. Then we update each row by reading the information of the second result based on a unique key, for example with a "Country". Or you can see your requests for all information with a single query. Try to implement these ideas and post back what is the output of your program.

  3. #3
    Join Date
    Dec 2009
    Posts
    211

    Re: Fill JTable with several values

    Hello
    We can do this in two steps: first we fill the table with the first result. Then we update each row by reading the information of the second result based on a unique key, for example with a "Country"
    That's what I tried to fill JTable with the first result then spent the 2nd, but I get the result of the 2nd query in the first column with the results of the first
    Or you can see your requests for all information with a single query.
    This is not feasible because I have not the same registration number for each request.

  4. #4
    Join Date
    Dec 2009
    Posts
    204

    Re: Fill JTable with several values

    Hello,
    I have a similar kind of problem, but I think I am step ahead of this one. Here is my code.
    Code:
    or(.......){
    if (recset.next(){
     
    .......
    row.add(recset.getString(i));
    }
    if (recset1.next()){
    row.add(recset1.getString(i));
    }
    data.add(row)
    }
    Remains a problem but I want to display data that are in the same line. I this possible.

  5. #5
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Fill JTable with several values

    Hello,
    First you fill the table with the first result. Then you update each row of TableModel -> table.getModel () by reading the information of the second result. You can do this by example based on a unique key through a "Country". Using the method
    "TableModel # setValueAt (Object aVal, int rwInd, int colInd)"
    You can choose exactly the column where you want to save the values of "country".

  6. #6
    Join Date
    Dec 2009
    Posts
    211

    Re: Fill JTable with several values

    Hello,
    Thank you for your answer but I really do not see how going through setValueAt then it must test the values in filling the JTable style if the value of the 1st line of 1st column = the 1st row of the 3rd column then write the value X. I am going to use this method in my program. If you see any alternative to this, then please do post back.
    Last edited by Logan 2; 19-01-2010 at 02:41 PM.

Similar Threads

  1. W32 registry values are not getting matched by the default values
    By Angrzej in forum Networking & Security
    Replies: 5
    Last Post: 19-05-2011, 12:23 PM
  2. Editing JTable cells
    By Messenger in forum Software Development
    Replies: 5
    Last Post: 29-07-2010, 10:31 AM
  3. What is the use of JTable class?
    By Khan Baba in forum Software Development
    Replies: 5
    Last Post: 13-02-2010, 11:41 AM
  4. Print JTable with the help of java
    By Coldman in forum Software Development
    Replies: 3
    Last Post: 25-11-2009, 09:02 AM
  5. How to refresh data of Jtable in java
    By sarmad_iu in forum Software Development
    Replies: 1
    Last Post: 28-05-2009, 02:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,906,300.34651 seconds with 17 queries