This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

jtable selection  RSS feed

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can anyone help me on this. l am writing a java project and l don't know how can l select a row after l successfully found the contents on the jtable. this code do retrieve the contents from sql database and l want it also to highlight the jtable selected row.

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTable is the most complicated component in Swing, for me.
and needs some effort to be mastered. get a look at the TableModel and how it works

for your question ? JTable has this method,
 
anotida Maditsha
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Omar Rashwan. let me go through Tablemodel and look especially on the
setRowSelectionInterval(int index0, int index5) method.
 
Rancher
Posts: 2940
19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Selection has nothing to do with the TableModel. The TableModel just stores the data. The JTable displays the data and is responsible for the selection of rows.

In addition to the setRowSelectionInterval(...), JTable also supports addRowSelectionInterval(...) in you need to select multiple non contiguous rows.
 
Omar Rashwan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the TableModel i mentioned because I saw that you are retrieving data from a mysql database
and i know that you may suffer for that at the beginning, but the TableModel will save your time for retrieving and presenting Data...

but exactly the setSelectionInterval(0,1) as Rob mentoined its a JTable method not TableModel method...
and it selects for the first row till the second row in JTable the second index is ***inclusive.

and for better understanding of JTable you have to look at these good things
The JTable CellRenderer ,
The JTable TableModel ,
The JTable ColumnModel, The TableRowSorter

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!