Possible regressionn, popupmenus not appearing to work correctly with cntl-click
Paul Taylor
paul_t100 at fastmail.fm
Tue Oct 29 04:14:13 PDT 2013
On 28/10/2013 12:29, Leonid Romanov wrote:
> Hello,
> I've filed a bug:
> https://bugs.openjdk.java.net/browse/JDK-8027374
>
Hi, Ive think Ive found the issue for me , I created this test case and
it works correctly as you say
import javax.swing.*;
public class TableTest
{
public static void main(String[] args) throws Exception
{
JPopupMenu popup = new JPopupMenu("Popup");
popup.add(new JMenuItem("Copy"));
JTable test = new JTable(5,5);
test.setComponentPopupMenu(popup);
test.setRowSelectionAllowed(true);
test.setColumnSelectionAllowed(true);
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
JFrame frame = new JFrame();
frame.add(test);
frame.pack();
frame.setVisible(true);
}
}
But if you comment out the line
test.setComponentPopupMenu(popup);
so that there is no popup menu then it doesn't work, CntlClick will
change the selection.
Whether this is a bug, or correct behaviour Im not sure ?
But the reason why this is causing an issue for me in my current code is
that Im not using setComponentPopupMenu()instead I'm adding a mouse
handler to the table that then decides whether or not to show a popup
menu so I guess the logic for Jtable must not detect that it has a popup
menu in this case. I've checked and the method was not added to JTable
until Java 1.5 and my code was started before then so hopefully I can
just update my code to use the method and the problem will go away for me.
Paul
More information about the macosx-port-dev
mailing list