changing the image of a draw2d button after creation
-
06-06-2021 - |
Вопрос
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
Решение
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.
Другие советы
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.
Не связан с StackOverflow