How do I make a window in Java?

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

  • 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?

  • Answer:

    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

The Crazy Chimp at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

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 http://docs.oracle.com/javase/6/docs/api/javax/swing/JDialog.html#JDialog%28java.awt.Frame,%20java.lang.String,%20boolean,%20java.awt.GraphicsConfiguration%29 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

mKorbel

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.