0

Image of the problem:

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);
                }
            });

So as you have seen on the image, I don't think this is any accurate. Is there any (better) method to get it on a the right spot?

I have clicked on the JButton: "Settings" and it should popup just a tad down it.

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user2192658
  • 41
  • 1
  • 5
  • Post a SSCCE when you have a problem. This was mentioned in your last posting as well. I, as well as most users will continue to ignore postings when you can't make an effort to properly describe your problem. We don't have time to guess what you may or may not be doing. By definition when you have a problem you don't know what is wrong, so you don't know if the few random lines of code cause the problem or not. – camickr Apr 21 '13 at 17:43
  • @user2192658 did you get it resolved? – 0x6C38 Apr 24 '13 at 17:30

1 Answers1

1

You are better off using a JMenuBar and then adding JMenus with JMenuItems, there is no point on reinventing the wheel:

JMenuBar menubar = new JMenuBar();
JMenu settings = new JMenu("Settings");
JMenuItem accounts = new JMenuItem("Accounts");
settings.add(accounts);
menubar.add(settings);
myFrame.setJMenuBar(menubar);
0x6C38
  • 6,796
  • 4
  • 35
  • 47