Link to home
Start Free TrialLog in
Avatar of mcmahling
mcmahling

asked on

Adding a TableModel to an exisitng JTable at runtime

I am using NetBeans 6.1 for Mac to create a desktop application. I want to query a database and use an attached resultset to create a tablemodel that will be eventually used to fill a JTable that I created at runtime. I am new to java and can not find a way to attach a tablemodel to a jtable at runtime. Can anyone suggest some code?
ASKER CERTIFIED SOLUTION
Avatar of asiderop
asiderop
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
File->New project->Java->Java Desktop application->Database application.

Netbeans will build automagically the JTable connected to the database with buttons for adding, editing, removing, committing and rollbacking ;)
check this example to create your own table model and set to table,

https://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data