Search code examples
javaswingjpopup

How to create a drop-up menu in java swing


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


Solution

  • 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.