Ann Smith
Ann Smith

Reputation: 11

display results from a combo box in swt

I have a combo box with a list of entries and when I choose an entry eg dog I want to display an image of a dog beside the combo box. Would anybody have any examples of this in swt that I could take a look at?

Ann.

Upvotes: 1

Views: 366

Answers (1)

Mario Marinato
Mario Marinato

Reputation: 4617

Add a SelectionListener to your combo box.

    combo.addSelectionListener( new SelectionAdapter() {
        public void widgetSelected( SelectionEvent event ) {
            // ...
        }
    } );

On the widgetSelectedmethod, get the selection index - using combo.getSelectionIndex() -, map it to your image and display it wherever you want (e.g. on a Label: label.setImage(image)).

Upvotes: 3

Related Questions