GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes Swing JOptionPane showInputDialog : own textfield or combobox Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Swing JOptionPane showInputDialog : own textfield or combobox" Watch "Swing JOptionPane showInputDialog : own textfield or combobox" New topic
Author

Swing JOptionPane showInputDialog : own textfield or combobox

Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
Reading the API of JOptionPane in the most parameters showInputDialog (see copy below), at the end I
read :
It is up to the UI to decide how best to represent the selectionValues, but usually a JComboBox, JList,
or JTextField will be used.
Now in a JCombobox you are sure only one value is selected, in a list you can select more.
How can I make sure :
that I have a combobox,
or in case I will get a list, that only one value can be selected?
General idea is : how to make sure there is only one selection possible?
Please add codesnippit,
Thanks,
javabit
showInputDialog
public static Object showInputDialog(Component parentComponent,
Object message,
String title,
int messageType,
Icon icon,
Object[] selectionValues,
Object initialSelectionValue)

Prompts the user for input in a blocking dialog where the initial selection, possible selections, and
all other options can be specified. The user will able to choose from selectionValues, where null implies
the user can input whatever they wish, usually by means of a JTextField. initialSelectionValue is the
initial value to prompt the user with. It is up to the UI to decide how best to represent the selectionValues,
but usually a JComboBox, JList, or JTextField will be used.
An example will help me very much. Thanks.
Fatos Maxhuni
Greenhorn

Joined: May 10, 2001
Posts: 2
Well I ma not sure if I understood this question but to make sure
that you get a single value from a JList you can set the a a SINGL selection mode, i.e.
someList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
Originally posted by Alex Iordache:
Reading the API of JOptionPane in the most parameters showInputDialog (see copy below), at the end I
read :
It is up to the UI to decide how best to represent the selectionValues, but usually a JComboBox, JList,
or JTextField will be used.
Now in a JCombobox you are sure only one value is selected, in a list you can select more.
How can I make sure :
that I have a combobox,
or in case I will get a list, that only one value can be selected?
General idea is : how to make sure there is only one selection possible?
Please add codesnippit,
Thanks,
javabit
showInputDialog
public static Object showInputDialog(Component parentComponent,
Object message,
String title,
int messageType,
Icon icon,
Object[] selectionValues,
Object initialSelectionValue)

Prompts the user for input in a blocking dialog where the initial selection, possible selections, and
all other options can be specified. The user will able to choose from selectionValues, where null implies
the user can input whatever they wish, usually by means of a JTextField. initialSelectionValue is the
initial value to prompt the user with. It is up to the UI to decide how best to represent the selectionValues,
but usually a JComboBox, JList, or JTextField will be used.
An example will help me very much. Thanks.

 
GeeCON Prague 2014
 
subject: Swing JOptionPane showInputDialog : own textfield or combobox