Would it be possible to create a custom JMenuItem
that contains buttons? For example would it be possible to create a JMenuITem
with an item similar to this:
+----------------------------------------+
| JMenuItem [ Button | Button | Button ] |
+----------------------------------------+
I doubt there is an easy way to do this. You can do something like:
But there are several problems:
a) the menu doesn't close when you click on the button. So that code would need to be added to your ActionListener
b) the menu item doesn't respond to key events like the left/right arrow, so there is no way to place focus on the button using the keyboard. This would involve UI changes to the menu item and I have no idea where to start for this.
I would just use the standard UI design an create sub menus.
Old question, but you can do this fairly easily with a JToolBar...
I'm sure there is, Like personally I would use individual menuitems and just put them side by side and have an action listener for each individual button. The tricky part would be putting them inside a container like a JPanel and putting them in a flow layout or a Grid layout