Bugs item #1194591, was opened at 2005-05-03 19:15
Message generated for change (Settings changed) made by kriede
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=454391&aid=1194591&group_id=48863
Category: JXTable
Group: swing
>Status: Closed
Resolution: Accepted
Priority: 5
Submitted By: Iñaqui Medina (inaquimj)
Assigned to: Nobody/Anonymous (nobody)
Summary: addMouseListener doesn't work
Initial Comment:
When you add a mouse listener to a JXTable, the
methods of the listener are never called.
Probably something like:
public void addMouseListener(MouseListener ml)
{
getLockedTable().addMouseListener(ml);
getScrollTable().addMouseListener(ml);
}
Will fix it but then we have another problem: in the
mouse listener you'll probably try something like:
public void mouseClicked(MouseEvent me)
{
int col = table.colAtPoint(me.getPoint());
//do something with col
}
The problem is that the point in the event is relative to
one of the real tables, so if you try the previous code
and click on the scroll table you'll get the wrong col.
The way I solve it is by adding a colAtPoint method that
takes the MouseEvent instead of just the point to get
the source and compare it against the scroll table and
then just add getFrozenColumns() to the result.
This is not a neat solution... I guess the nice solution is
to save the listeners ourselves and add another one that
identifies the source of the click and creates a new
mouse event with a modified point and source and
passes this one to the listeners instead.
I assume colAtPoint still needs to be overriden and
compare x against getLockedTable().getWidth() to
identify the table to ask the "question" to.
Hope it's clear.
----------------------------------------------------------------------
Comment By: Kurt Riede (kriede)
Date: 2005-05-10 09:35
Message:
Logged In: YES
user_id=484961
support for the three listeners MouseListener,
MouseMotionListener and MouseWheelListener added.
What I did is to write a new implementation for the three
listener interfaces that delegates all events from the KTables
to the listeners of the JXTable with translated coordinates.
Also fixed a bug with calculation of x/y coordinates in method
JXTable.columnAtPoint().
Could you please test this?
As far as I see, your example of a mouseClicked event (using
method columnAtPoint) should now work as is withourr any
hacks.
I also think/hope that your new method colAtPoint
(MouseEvent) is not needed anymore.
Regards
Kurt
----------------------------------------------------------------------
Comment By: Iñaqui Medina (inaquimj)
Date: 2005-05-04 22:09
Message:
Logged In: YES
user_id=1086927
Well I just implemented the not-nice solution so I wouldn't do
it right away.
If you do it I'll test it.
----------------------------------------------------------------------
Comment By: Kurt Riede (kriede)
Date: 2005-05-04 00:10
Message:
Logged In: YES
user_id=484961
After short thinking, our own Listener sounds as the right way
to do it. Do you have the time and the need to implement
this, or would you like me to help providing some initial
changes?
I would then ask you to test and finalise it.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=454391&aid=1194591&group_id=48863
-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
|