• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to work with Table Model?

 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic