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

How to get selected cell from selected area?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say you have a table. You do an area select within the table (click&drag or click&shift-click). Then you do some sort of a search function or the like that results in a cell within the selected area being highlighted. That is, some operation that results in something like: table.changeSelection(row, column, true, true);

So now you have a selected area with a highlighted cell. How do you determine what cell is highlighted? The functions table.getSelectedRow() and table.getSelectedColumn() will give you the top/left cell of the selected area. But I can't find any other functions that will give me the location of that one cell.

Any ideas? Thanks.
 
Brett Carver
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would prefer to not setup a listener for this. Seems like overkill just to find the current selection.

In another forum I was given this link: http://javaalmanac.com/egs/javax.swing.table/GetAnchor.html?l=rel

It demonstrates the use of the Anchor point which I believe will solve my problem. I've prototyped it and it seems to work correctly (giving me the location of the specific cell within the larger selected area).
 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic