Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default value/Item for SWT Combo

Tags:

swt

A would like to add default text when the drop-down menu is loaded on my view. How can I do this in SWT and JFace?

like image 934
sonx Avatar asked Jul 05 '11 14:07

sonx


1 Answers

I'm guessing what you want to do is to show something in the combo when it has been added to the view (it's blank by default until something is selected or typed).

If you want to set a default text displayed until a selection has been made / until the field has been edited, e.g. - Select option -, then you can use:

Combo.setText(String string)

Note, this is not possible if the Combo is SWT.READ_ONLY

If you want to set one of the values in the drop-down as default use the select method:

Combo.select(int index)
like image 161
Anders Avatar answered Oct 19 '22 19:10

Anders