wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes how to work with Table Model? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to work with Table Model? " Watch "how to work with Table Model? " New topic
Author

how to work with Table Model?

Yuta Lolap
Ranch Hand

Joined: Jun 03, 2012
Posts: 80

Hey guys,

Can anyone please explain with code how to work with Jtable in Netbeans using a tablemodel that appears by default when you add table component to your Jframe form.

I am facing issues retrieving data from the database into the dragged component.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
I don't use netbeans, so this may not be exact.

from your description, generally you'd add this to your code

DefaultTableModel dtm;
dtm = (DefaultTableModel)table.getModel();
or
DefaultTableModel dtm = (DefaultTableModel)table.getModel();
//depends on required scope: class field, or local variable

in netbeans (I think) there's a call to an auto-generated initComponents()
called from a static(?) createAndShowGUI() (?)
if so, in createAndShowGUI(), it would go something like this

then you'd need to handle the static part
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to work with Table Model?
 
Similar Threads
Table Model and Table Cell Renderer
TableModelEvent question: fires AFTER user has navigated away from cell, not what I need
javascript calendar
JTable cell focus
Problem in Scrolling in a table