/**
* Adds support changing icons by pressed.
*
* @param button the button.
*/
@FXThread
public static void addSupport(@NotNull final ButtonBase button) {
final EditorConfig editorConfig = EditorConfig.getInstance();
final CssColorTheme theme = editorConfig.getTheme();
if (!theme.needRepaintIcons()) {
return;
}
final ImageView graphic = (ImageView) button.getGraphic();
final Image image = graphic.getImage();
final Image original = FILE_ICON_MANAGER.getOriginal(image);
final ObservableMap<Object, Object> properties = button.getProperties();
properties.put(NOT_PRESSED_IMAGE, image);
properties.put(PRESSED_IMAGE, original);
button.pressedProperty().addListener((observable, oldValue, newValue) -> {
if (newValue) {
graphic.setImage((Image) properties.get(PRESSED_IMAGE));
} else {
graphic.setImage((Image) properties.get(NOT_PRESSED_IMAGE));
}
});
if (button.isPressed()) {
graphic.setImage(original);
} else {
graphic.setImage(image);
}
}
DynamicIconSupport.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:jmonkeybuilder
作者:
评论列表
文章目录