3import java.awt.BorderLayout;
4import java.awt.Component;
5import java.awt.Dimension;
7import java.awt.event.ActionEvent;
8import java.awt.event.ActionListener;
9import java.util.ArrayList;
12import javax.swing.BoxLayout;
13import javax.swing.JButton;
14import javax.swing.JCheckBox;
15import javax.swing.JPanel;
16import javax.swing.JPopupMenu;
17import javax.swing.JScrollPane;
18import javax.swing.SwingConstants;
43 public void showMenu(Component invoker,
int x,
int y)
45 menu =
new JPopupMenu();
46 menu.setLayout(
new BorderLayout());
54 JScrollPane scrollablePane =
new JScrollPane(
menuPanel);
55 scrollablePane.setPreferredSize(
new Dimension(450,400));
56 menu.add(scrollablePane, BorderLayout.CENTER);
58 JButton doneBtn =
new JButton(
"Done");
59 doneBtn.addActionListener(
new ActionListener(){
60 public void actionPerformed(ActionEvent e){
61 menu.setVisible(
false);
64 menu.add(doneBtn, BorderLayout.SOUTH);
67 menu.setInvoker(invoker);
68 Point invokerOrigin = invoker.getLocationOnScreen();
69 menu.setLocation((
int) invokerOrigin.getX() + x,
70 (int) invokerOrigin.getY() + y);
71 menu.setVisible(
true);