Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to take the data out from JTable?

 
Richard Phen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method of JTable is used for taking data from JTable? For example, I select one row from JTable and want to take this row data out and specified column[9] to compare some number which is the amount I want to book.
I hope I express clearly what I want to ask. Please help. Thanks a lot!
 
Chiji Nwankwo
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have not tried this, but you can give it a go,

Im not sure how you creating your table.
I think the jtable might have its own default TableModel.
Chiji
 
Richard Phen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should I add a mouseListener to this JTable?
Thanx!
 
Chiji Nwankwo
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try and give a bit more information or code samples even, so that we can help out. I am giving you answers based on assumptions that I am making about you scenario and code.
Chiji.
 
Richard Phen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is my GUI:
Select data from 1st row of JTable and compare to the seat#.
Help!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard, if you use .trim() method of the String class, then you can get rid of those boxes in your JTable. in the readRecord method of the Data class. probably the same line you changed to fix the deprecated method in that method.
Mark
 
Richard Phen
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it done! Thank you all!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic