Brett Carver

Greenhorn
+ Follow
since Oct 21, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Brett Carver

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).
19 years ago
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.
19 years ago
Well it's been a while with no replies. Can anyone help me here? Is there a change in behavior (I need to "fix" my code) or is there are true problem with Java 1.5?
19 years ago
The application I'm working on has a search function for a large table of data. In addition, you can restrict the search to a selected area of the table. This worked fine when compiled on Java 1.4 (1.4.2_06), but has stopped working on Java 1.5 (1.5.0_03). It appears the problem is with JTable.changeSelection() not actually changing the selection to the cell that was found in the search.

I've been able to reproduce the problem with some small modifications to the SimpleTableSelectionDemo.java tutorial program. I've included the code below with my changes.

Basically all I did was modify the mouseListener so that instead of printing the table contents, it calls changeSelection to a fixed location (simulating the search going to a matching cell).

If I compile/run in 1.4, I can select a cell or region, right-click the mouse and see the specified cell selected. If I start typing the selected cell is edited.

If I compile/run in 1.5, when I right-click the selected cell is not changed (the second selected cell of the select region stays selected). If I start typing the wrong cell is edited.

Hopefully someone can tell me if this is a pilot error, a run-time bug, or a change in behavior (and what I need to do to get it working again in 1.5).

Thanks.

19 years ago