问题
I am working on Java Swing, making an UI. I have a Panel (Panel 1) with information, and I want to create a dropdown menu, but not like de comboBox. Is hard to explain.
I see the panel, and in the bottom, I have a button. When I press this button, I want to make appear another panel (transparent) on Panel 1.
I dont know how can I do that.I wait for yoir help, if I have explained it well.
I dont want the typical dropdown list, is like a dropdown panel.
EDIT: for example, in the main page of google, when you hit a button above, appears a new menu, but not a list. I see that is not a good example, i am searching another better example for it.
EDIT 2: I need that the thing that appear when I press the button will be a Panel, because I need to add some JOGL on it.
回答1:
You can use PopupFactory for this .
PopupFactory factory = PopupFactory.getSharedInstance();
Popup popup = factory.getPopup(myButton, myPanel, x, y);
popup.show();
x and y are screen coordinates.
来源:https://stackoverflow.com/questions/34855469/swing-drop-down-panel