Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » ComboViewer - selections cannot show icons
ComboViewer - selections cannot show icons [message #1261046] Sun, 02 March 2014 05:44
David Lee is currently offline David LeeFriend
Messages: 50
Registered: May 2013
I tried showing images in TableViewer and TreeViewer by using getImage() like function in LabelProvider, all works very well!

I'd like to implement a Combo with flags/languages just like the picture in "Shadows" paragraph of

I tried ComboViewer, the getText() of LabelProvider works well, but the getImage() does not work at all, it cannot show the flag icons! the code is as below, can someone please let me know why?! Thank you!

// where compComboViewer is a Composite container
final Image flagAmerica = SysIcon.loadImage("icon/America.png");
final Image flagChina = SysIcon.loadImage("icon/Canada.png");

// to test if 16x16 icon flagAmerica works, and the answer is YES
Label label = new Label(compComboViewer, SWT.NONE);

final ComboViewer cboLocale = new ComboViewer(compComboViewer, SWT.READ_ONLY);
cboLocale.setLabelProvider(new LabelProvider() {
public String getText(Object element) {
Country country = (Country) element;
return country.getCountryName();
public Image getImage(Object element) {
Image imgFlag = null;
Country country = (Country) element;
switch ( country.getCountryName() ) {
case "America":
imgFlag = flagAmerica;
case "Canada":
imgFlag = flagCanada;
return imgFlag;
Country[] countries = new Country[]{ new Country("America"), new Country("Canada") };

private class Country {
private String countryName;
public Country(String countryName) {
this.countryName = countryName;
public String getCountryName() { return this.countryName; }
public void setCountryName(String countryName) { this.countryName = countryName; }
  • Attachment: Shadows.png
    (Size: 17.52KB, Downloaded 94 times)
Previous Topic:ComboViewer - flag icons cannot appear
Next Topic:ComboViewer - selections cannot show icons
Goto Forum:

Current Time: Thu May 24 15:40:58 GMT 2018

Powered by FUDForum. Page generated in 0.01301 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top