This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

About JFrames

 
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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • 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...)
 
    Bookmark Topic Watch Topic
  • New Topic