Search code examples
eclipseeclipse-plugindraw2d

changing the image of a draw2d button after creation


I am writing an eclipse plugin using draw2d. I am creating a draw2d button using the constructor : Button(Image image). At some point I want to change the image on that button! I can not find a way of doing it. Can anyone help me please?

Kind Regards, Kyriakos


Solution

  • You could do the following:

    Button button = ...
    Image newImage = ...
    
    ((Label) button.getChildren().get(0)).setIcon(newImage);
    

    It's certainly not nice, but it seems to be the only option.