[ xframe-Bugs-1194591 ] addMouseListener doesn't work

"SourceForge.net" <[email protected]> Tue, 03 May 2005 15:10:10 -0700
Newsgroups gmane.text.xml.xframe.xsddoc
Message-ID <[email protected]>
Bugs item #1194591, was opened at 2005-05-03 19:15
Message generated for change (Comment added) 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: Open
Resolution: None
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-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: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great events, 4
opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20