How to make a java swing popup window with combo box and 2 buttons?

13,650

Solution 1

You can use the JOptionPane to achieve this. Please refer to the link below which explains this with sample code:

http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html#input

Solution 2

JOptionPane.showInputDialog may be good enough if you are willing to leave how exactly the options are presented up to the UI.

Solution 3

I need to make a popup box with with a combo box and a couple of buttons

1) don't use another JFrame as popup window, use JFrame with JOptionPane/JDialog/JWindow these container are same as JFrame, but can take parent and owner

2) don't forget to setParent

3) depends if you needed decorated window then use JDialog, don't forget look for setModal() or ModalityTypes, if undecorated then use JWindow

4) don't create lots of JOptionPane/JDialog/JWindow on fly, becasue there Object are still in JVM memory, create this Container once and re-use that (by removing child) for another Action

Share:
13,650
Admin
Author by

Admin

Updated on June 09, 2022

Comments

  • Admin
    Admin almost 2 years

    I need to make a popup box with with a combo box and a couple of buttons. Please could someone advice on the best way to achieve this? I've had a look around and all I can find is alert boxes. Is this possible or will I need to create a whole new frame?