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!

How to clear a combo box

edward17Apr 8 2013 — edited Apr 9 2013
OK, been a while, here goes:

I have a non-edittable combobox and 3 radio buttons.

When I select a radio button, I reset the items in the list, and execute :
    category.getSelectionModel().clearSelection();
     category.setValue(null);
The intent is a new list, nothing preselected, and the prompt showing inthe text(?) box. And it seems to work at first.

However, when I select the original radio button, the first list is restored, and the combo box shows my original selection!

I would like the prompt to be displayed as with the other radio buttons. I can't even find where the originally select value is stored! It LOOKS like the selection is cleared, as is the value, but the renedered control still shows a selection, even though with the previous list it showed the prompt
     templateToggle.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
            @Override
            public void changed(ObservableValue<? extends Toggle> ov,
                    Toggle old_toggle, Toggle new_toggle) {

                if (templateToggle.getSelectedToggle() != null) {
                    final String tmplType = ((RadioButton) templateToggle.getSelectedToggle()).getText();
                    Preferences.userNodeForPackage(Evidentia.class).put(Const.O_TMPL_TYPE,
                            tmplType);

                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            category.getSelectionModel().clearSelection();
                            category.setValue(null);
                            category.getEditor().setText("");  << was getting desparate
                            ListManager.getInstance().setTemplateCategoryList(TemplateDao.getInstance().findCategories(tmplType));   << template list is the list behind the combo
                        }
                    });

                }
            }
        });
Thoughts?

Edited by: edward17 on Apr 8, 2013 11:20 AM

Edited by: edward17 on Apr 8, 2013 5:11 PM

Edited by: edward17 on Apr 8, 2013 5:12 PM
This post has been answered by James_D on Apr 8 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 7 2013
Added on Apr 8 2013
7 comments
3,687 views