Since I am on neither team :-) I used a workaround that looked like
this. Inside any JTable that I am using I override updateUI() like
this:
public void updateUI() {
super.updateUI();
ForwardingTableUIMouseListener.fixMouseListeners(this);
}
And then add a class ForwardingTableUIMouseListener to delegate as
appropriate and filter out the popup triggers. This class looks like
this:
/**
* Copyright (C) 2002 Smartspread Ltd.
* All rights reserved.
*
* Created: 15-Oct-02 14:23:19
*/
package com.smartspread.smartspread.impl;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.util.EventListener;
import javax.swing.JTable;
import javax.swing.plaf.basic.BasicTableUI;
/**
* This class exists to deal with a defect that has fallen between the
Apple/Sun
* cracks for MacOS Java with selection changes on Alt-click mouse
clicks.
* Currently Alt-clicks don't get ignored and so selection
* changes when they occur. Until this gets fixed by Sun or Apple we
add a new
* ignore for the MouseHandler from BasicTableUI, and delegate
everything else.
*
* There is no defect report in the Sun Bug database as they don't
allow you to
* submit Mac defects. There is no defect report for Mac as I can't
work out
* how to post one. Sorry for the lack of references.
*/
public class ForwardingTableUIMouseListener implements MouseListener {
private MouseListener _delegate;
public static void fixMouseListeners(JTable table) {
// in general there will only be one, but removing and then
readding all is
// more correct, and in the case where there is only one isn't a
big
// efficiency hit
EventListener [] listeners =
table.getListeners(MouseListener.class);
// this remove may seem unnecessary but keeps all MouseListeners
in the same
// order
for (int i = 0; i < listeners.length; i++) {
table.removeMouseListener((MouseListener)listeners[i]);
}
// now add them back on, wrapping any as necessary
for (int i = 0; i < listeners.length; i++) {
MouseListener listener = (MouseListener)listeners[i];
if(listener instanceof BasicTableUI.MouseInputHandler) {
table.addMouseListener(new
ForwardingTableUIMouseListener(listener));
} else {
table.addMouseListener(listener);
}
}
}
private ForwardingTableUIMouseListener(MouseListener delegate) {
_delegate = delegate;
}
protected boolean shouldIgnore(MouseEvent e) {
return e.isPopupTrigger();
}
public void mouseClicked(MouseEvent e) {
if(!shouldIgnore(e)) {
_delegate.mouseClicked(e);
}
}
public void mousePressed(MouseEvent e) {
if(!shouldIgnore(e)) {
_delegate.mousePressed(e);
}
}
public void mouseReleased(MouseEvent e) {
if(!shouldIgnore(e)) {
_delegate.mouseReleased(e);
}
}
public void mouseEntered(MouseEvent e) {
_delegate.mouseEntered(e);
}
public void mouseExited(MouseEvent e) {
_delegate.mouseExited(e);
}
}