Win a copy of Event Streams in Action this week in the Java in General 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

getting the position of cell

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
i have a JFrame which has a toolbar and 2 JInternalFrames(each of which contains 1 JTable).
when i select a cell in any of the JTables and click a button in the tool bar,i should get the value of the cell.
could anybody help me in this issue,
thanks in advance
lavanya
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
If you are only going to have two tables you could ask each table to supply it's selected cell value:

To do this the tables must be visible outside the JInternalFrames
If you want a more flexible model then try adding a MouseAdapter to the tables passing a reference to the owner JInternalFrame in the MouseAdapter constructor and have the mousePressed event pass that reference back to a setSelectedInternalFrame() method which changes a variable in your program so the last JInternalFrame operated on is always known.
Extend the JInternalFrame class and when adding the table create a variable "table" and give it a reference to the table. Include a getTable() method that returns a JTable.
Then the code to get the value would change:

Now it doesn't matter how many InternalFrames you have in the future.
P.S.: You might want to consider returning a copy of the table( a new table with the same contents) instead of a reference if you want to protect the integrety of the original table and it's data.
Hope that helps,
 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Terry,
thanks,it's working
lavanya
 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Terence,
sorry for my misspell your name in my previous mail.
it's working but
when i make a selection in the table in the first frame the second frame is instantiated and works fine.
but when i make another selection in the table in the first frame the second frame is instantiated and displays fine.but when i click the second frame the previous selection retains there,so what should i doto get the value updated.
help is appreciated,
lavanya
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!