• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get selected cell from selected area?

 
Brett Carver
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).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!