• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get cell values of a JTable row.

 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to get all cell values of a row (that was clicked) when I click a button outside the table. How to do this?
I have an action listener for this button. In the actionPerformed() method I have access to the table object.
Thanks.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like this should work...


Of course, you can replace the array with a Vector, ArrayList, Hashtable, etc.
[ December 21, 2002: Message edited by: Nathan Pruett ]
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks alot!
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Nathan Pruett,
Normally if we want to delete a particuler record in databasee which is by clicking a button in my application but i want to delete a particular record by clicking the entire row of JTable. The problem is how the system know which record in database i wish to delete by just click on the entire row? How should the code will liik like.
Thank you in advance!
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kevin,
JTable doesn't "understand" your database. You must include in the JTable (or the underlying TableModel) sufficient information to identify the row in your database. This may be the key column value(s) for the database table, a rowid, or whatever you plan to use in your database delete statement. When someone clicks on a JTable row, it's up to your Java code to retrieve the information identifying the row (from the TableModel) and use it in the delete statement.
You don't have to display that information in the JTable, of course. You can have lots of columns in a TableModel that are not display in the JTable.
 
Morning came much too soon and it brought along a friend named Margarita Hangover, and a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic