• Post Reply Bookmark Topic Watch Topic
  • New Topic

About JFrames

 
sachin dabhade
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody tell me how to add data to a JTable??
i have a text box and a button and want to add the data to the JTable on clicking the button.
thanks in davance.
sachin
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to get the table's model(JTable.getModel()). If this is a DefaultTableModel, you can use the addRow() method, which takes either an Object array or a Vector. (You'll need to cast the TableModel that is returned from JTable.getModel() into a DefaultTableModel if you want to do this. If you are using some other TableModel that doesn't inherit from DefaultTableModel, you'll need to talk to whoever made the class...)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!