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.
Question
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
La 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.
Autres conseils
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);
}
});