Link to home
Create AccountLog 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
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
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