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
Other answers
http://docs.oracle.com/javase/7/docs/api/javax/swing/JOptionPane.html#showInputDialog%28java.awt.Component,%20java.lang.Object,%20java.lang.String,%20int,%20javax.swing.Icon,%20java.lang.Object%5B%5D,%20java.lang.Object%29 may be good enough if you are willing to leave how exactly the options are presented up to the UI.
kyle_wm
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:
- how to Create a Java Package from MATLAB Code?Best solution by Stack Overflow
- How to load a Java web app in the terminal?Best solution by stackoverflow.com
- How to create a java applet?Best solution by Stack Overflow
- Dose anyone know how to make a toga without cutting a sheet?Best solution by Yahoo! Answers
- How do make a website and make money from it?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
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.