The tool tips should be fairly easy to get working.  JTable returns
the tool tip of the renderer by default.  The renderer will be being
asked for its tool tip with the mouse event translated into its own
co-ordinates.  I suspect the problem is that your renderer is not using
this event to work out the appropriate label's tool tip.  I take it that
these labels are in something like a JPanel.  In this case its the JPanel
that will be asked for its tool tip.  You need to use a subclass of
JPanel with getToolTipText overridden with something like:

    public String getToolTipText(MouseEvent event) {
        JComponent comp = (JComponent) getComponentAt(event.getPoint());
        String result;

        if (comp == null) {
            result = super.getToolTipText(event);

        } else {
            MouseEvent compEvent = 
                SwingUtilities.convertMouseEvent(this, event, comp);

            result = comp.getToolTipText(compEvent);
        }
        return result;
    }

JTable doesn't, AFAIK, do a similar translation of the event when it does a
selection. I think you'll need to add your own mouse listener to the JTable 
and control the selection in that manner. Use columnAtPoint and rowAtPoint
to determine the cell indices.  Then use getCellRenderer and lastly
SwingUtilities.convertPoint to translate the event into the renderer's
terms.

Regards

Dave Wathen
Goldman Sachs Asset Management
3rd Floor, Procession House
55 Ludgate Hill
London EC4M 7JN
+44 (0)20-7774-2998

It is not necessary to understand things in order to argue about them.
(Caron de Beaumarchais)


-----Original Message-----
From: Wilbert Jackson [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 16, 2001 2:15 PM
To: [EMAIL PROTECTED]
Subject: JTable mouse events on multiple items in a cell



Hi,

I have a JTable which displays multiple JLabel components in a single
cell. Does anyone know how I can perform mouse hit detection to identify
each individual component in a cell, as well as assign tooltips text to
each component in a cell. I have tried a custom renderer, but I am
unable to determine which component has been selected.

Thanks

_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing
_______________________________________________
Advanced-swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/advanced-swing

Reply via email to