-2

I've tried searching for quite some time now, but I guess either I'm unable to find the exact keyword or there is no solution available.

I want to create a menu in the footer of my JFrame, such that on clicking, it drops-up unlike normal menus that drops-down

On what exactly I mean by drop-up, please see a similar menu in css -http://www.cssplay.co.uk/menus/final_pullup.html

mKorbel
  • 109,525
  • 20
  • 134
  • 319
coding_idiot
  • 13,526
  • 10
  • 65
  • 116
  • 2
    please consider adding comment while voting down, so that I can improve – coding_idiot Nov 24 '13 at 11:44
  • Check this example [here][1], its very helpful [1]: http://stackoverflow.com/questions/16475417/make-jpopupmenu-display-with-a-certain-bottom-left-coordinate – Salah Nov 24 '13 at 12:19

2 Answers2

3

One possibility is using buttons with JPopupMenu. The menu location can be specified when showing the menu:

menu.show(parentComponent, 0, -menu.getPreferredSize().height);

would place the menu above parentComponent like in the link.

kiheru
  • 6,588
  • 25
  • 31
0

Here is the sample code for others who stumble upon this question :

JPopupMenu popupMenu = new JPopupMenu();

        JMenuItem mnuNew = new JMenuItem("New");
        popupMenu.add(mnuNew);
        JMenuItem mnuOpen = new JMenuItem("Open");
        popupMenu.add(mnuOpen);
        JMenuItem mnuClose = new JMenuItem("Close");
        popupMenu.add(mnuClose);

        JButton btnMenu = new JButton("Popup");
        btnMenu.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                popupMenu.show(btnMenu, 0, -popupMenu.getPreferredSize().height);
            }
        });
coding_idiot
  • 13,526
  • 10
  • 65
  • 116