views:

1869

answers:

2

Hello, is there any way to add a JMenuItem to a JPanel so that I can create a button to show multiple options, like the latest news button in firefox, under the address bar?

I can only add JMenu and JMenuItems to a JMenuBar, JPopupMenu and other JMenus and JMenuitems

Is there any way to create in Java Swing a drop down Jbutton? (the ones with an down arrow in their left which shows more options to the user)

Thanks in advance

+3  A: 
VonC
It works but i finnally not use it in order to not depend of an external jar in the app, which is distributed by JavaWebStart. I do it by showing a popmenu on point 0,comp.getHeight() of the button
Telcontar
+4  A: 

Finnally i implement the "show options button" with a simple Jutton, and a JPopupPane with the options to show:

In the ActionPerformedListener of the button i write this code:

popMenu.show(showOptionsButton,0,showOptionsButton.getHeight())

It works fine like a JMenu in a JMenuBar, but not exactly like a dropdown button, in which you can perform an action pressing the button or show more actions pressing the down arrow. I believe this can be done ussing two buttons "very close", then use the code above in the arrow button, but setting the "action button" as the component of the popup, so that the popup shows below of both buttons.

Telcontar
Thank you for this feedback. +1
VonC