Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Add a row to a JTable

jakewendtjakewendt Posts: 18Member

Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.

Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.

TIA
Jake

Comments

  • bashirobashiro Posts: 244Member
    Are you talking of how to add records data to the table ?
    I am asking this because when you add a record into a
    table with columns a row is automaticallt generated to
    add the recods.

    Or did I misunderstood ?

    bashiro


    :
    : Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.
    :
    : Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.
    :
    : TIA
    : Jake
    :

  • jakewendtjakewendt Posts: 18Member

    What I mean is that if you've got a table, like the one below ...

    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/SimpleTableDemo.java

    ...and I want to add another person to the list. I suppose you could equate it to adding another record to a database. With JList or JComboBox you can use .addItem or something, but I can't find anything equivalent for a JTable.



    : Are you talking of how to add records data to the table ?
    : I am asking this because when you add a record into a
    : table with columns a row is automaticallt generated to
    : add the recods.
    :
    : Or did I misunderstood ?
    :
    : bashiro
    :
    :
    : :
    : : Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.
    : :
    : : Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.
    : :
    : : TIA
    : : Jake
    : :
    :
    :

  • bashirobashiro Posts: 244Member
    [b]
    What you can do is to create an instance of a Vector, HashTable or
    HashMap and then get user inputs and store it in one of the above.
    Later you populate JTable with the values.
    You can also get the user input and add it to the array. In this case
    you have to create (example a text file) and write to it for storage.
    Example ;
    [code]
    Vector table = new Vector();
    or
    HashMap hm = new HashMap();

    [/code]


    The best way is to use a pure database sofware like Oracle, Ms Sql, Mysql (this is free), ms Access and many more. In this case you edit your tabel and let the DAtabase program take care of the storage (of course you have to use sql commands).

    For the mean time take a look at suns Insertion of row example:
    http://java.sun.com/docs/books/tutorial/jdbc/jdbc2dot0/sample.html
    [/b]

    Hope this helps

    Bashiro





    :
    : What I mean is that if you've got a table, like the one below ...
    :
    : http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/SimpleTableDemo.java
    :
    : ...and I want to add another person to the list. I suppose you could equate it to adding another record to a database. With JList or JComboBox you can use .addItem or something, but I can't find anything equivalent for a JTable.
    :
    :
    :
    : : Are you talking of how to add records data to the table ?
    : : I am asking this because when you add a record into a
    : : table with columns a row is automaticallt generated to
    : : add the recods.
    : :
    : : Or did I misunderstood ?
    : :
    : : bashiro
    : :
    : :
    : : :
    : : : Is there any way to add a row to a JTable at Runtime? I see that there is an addColumn and a columnAdded method, but nothing for Rows.
    : : :
    : : : Anybody got any ideas? I basically just need a multi field list to hold a list of variables and there values.
    : : :
    : : : TIA
    : : : Jake
    : : :
    : :
    : :
    :
    :

  • jabduliusjabdulius Posts: 1Member
    I'm experiencing a similar problem and could really use some help. I've created a jTable in NetBeans 6.9.1, bound it to a MySQL table and a the elements to a list. When I update the list, however, the table is not updated.

    I've verified that in the persistence.xml, an entity class is created and included for the table in question.

    What am I doing wrong? Any thoughts or suggestions would be very much appreciated.

    Thanks!
Sign In or Register to comment.