Pergunta

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

Foi útil?

Solução

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.

Outras dicas

Can't be done. The function that sets the image on the button is Clickable.setContents, which is protected. There is nothing in the documentation telling why this was done... You can try to inherit from Button and adding a new function to implement this.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top