1 | import javax.swing.JFrame;
|
---|
2 | import javax.swing.JLabel;
|
---|
3 | import javax.swing.JPanel;
|
---|
4 | import javax.swing.JPopupMenu;
|
---|
5 |
|
---|
6 | class MouseDragPopup {
|
---|
7 | public static void main(String[] args) {
|
---|
8 | final JFrame frame = new JFrame("Mouse Drag Popup");
|
---|
9 | final JPanel panel = new JPanel();
|
---|
10 | final JPanel innerPanel = new JPanel();
|
---|
11 | final JPopupMenu menu = new JPopupMenu();
|
---|
12 | menu.add("This should not appear (and does not under Linux/Windows)");
|
---|
13 | innerPanel.setComponentPopupMenu(menu);
|
---|
14 | panel.add(new JLabel("Right click and drag from here"));
|
---|
15 | panel.add(innerPanel);
|
---|
16 | panel.add(new JLabel("to here"));
|
---|
17 | frame.add(panel);
|
---|
18 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
---|
19 | frame.pack();
|
---|
20 | frame.setVisible(true);
|
---|
21 | }
|
---|
22 | }
|
---|