问题图片:
http://gyazo.com/56c4f7f5fc10805695fc80de567b92c5.png
private JButton settingsButton = new JButton("Settings");
private JPopupMenu settings = new JPopupMenu();
private JMenuItem accounts = new JMenuItem("Accounts");
settings.add(accounts);
settingsButton.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
settings.show(e.getComponent(), 0, 0);
}
});
因此,正如您在图像上看到的那样,我认为这不准确。有没有(更好的)方法可以将它放在正确的位置?
我点击了JButton:“设置”,它应该会弹出一点点。