Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JOptionPane with Two Combos

843805Mar 2 2006 — edited Mar 5 2006
I would like to display two combo boxes side by side in a JOptionPane to allow the user to set both before selecting OK.

Can this be done with a small change?

In my code example I would like a combo with the otherValues to the right of the combo with the possibleValues in it.
import javax.swing.JOptionPane;

public class MultiComboOptionPane {

	public static void main(String[] args) {

		// Selection Set 1
		Object[] possibleValues = { "One", "Two", "Three" };
		// Selection Set 2
		Object[] otherValues = { "Apple", "Pear", "Orange" };
		
		Object selectedValue = JOptionPane.showInputDialog(null,
				"Select Number",
				"MultiCombo",
				JOptionPane.QUESTION_MESSAGE,
				null,
				possibleValues,
				possibleValues[0]);
	}

}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 2 2006
Added on Mar 2 2006
11 comments
831 views