JTable - DefaultTableModel

Discussion in 'Java' started by pat270881, Apr 11, 2005.

  1. pat270881

    pat270881 Guest

    Hello,

    I have a JTable with a DefaultTableModel. I have a search Methode which
    searches in the database and displays the results in the JTable. Now I
    want to extract the search from the class and put it in an extra class.
    I have for both the JTable and the DefaultTableModel defined getters
    and setters and now I want to write the following code in the
    outsourced method:

    Search.getTable().setVisible(true);
    search.getModel().addRow(new Object[]{name,text});

    Search is the class where the JTable and the DefaultTableModel is
    defined. Both lines are in a loop of a Vector size and the data of the
    vector are in the name and text parameters of the addRow Method. The
    problem is that this does not work and the rows are not displayed when
    I start my Java Application. When I put this code (without the Search
    prefix and the get-Method) it works without problems.

    Is it not possible to address the table and the model in that way from
    another class?

    lg
     
    pat270881, Apr 11, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aloys Oberthuer
    Replies:
    3
    Views:
    7,573
    Aloys Oberthuer
    Apr 22, 2004
  2. Deshaies
    Replies:
    3
    Views:
    4,572
    Deshaies
    Apr 20, 2004
  3. Parvinder
    Replies:
    2
    Views:
    7,045
    PuneetNanda9
    Jun 15, 2012
  4. Cyril Dex

    DefaultTableModel

    Cyril Dex, Sep 20, 2004, in forum: Java
    Replies:
    2
    Views:
    3,722
    Nigel Wade
    Sep 21, 2004
  5. Replies:
    0
    Views:
    315
Loading...

Share This Page