}
text = toString(data);
// Update the image view
MenuBar.Item menuBarItem = (MenuBar.Item)button;
MenuBar menuBar = (MenuBar)menuBarItem.getParent();
if (icon == null) {
imageView.setVisible(false);
} else {
imageView.setVisible(true);
imageView.setImage(icon);
imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f);
}
// Update the label
label.setText(text != null ? text : "");
if (text == null) {
label.setVisible(false);
} else {
label.setVisible(true);
Font font = (Font)menuBar.getStyles().get("font");
label.getStyles().put("font", font);
Color color;
if (button.isEnabled()) {
if (highlighted) {
color = (Color)menuBar.getStyles().get("activeColor");
} else {
color = (Color)menuBar.getStyles().get("color");
}
} else {
color = (Color)menuBar.getStyles().get("disabledColor");
}
label.getStyles().put("color", color);
}
}