private void calculateNewDimensions() { Dimension2D dim = calculateButtonDimensions(button); // add padding ImageFactory imageFactory = new ImageFactory(); Image img = imageFactory.getSlabImage(dim); imageView.setImage(img); }
public OpenPatricianStoneButtonSkin(final OpenPatricianStoneButton button) { super(button); this.button = button; Dimension2D dim = calculateButtonDimensions(button); ImageFactory imageFactory = new ImageFactory(); Image img = imageFactory.getSlabImage(dim); imageView = new ImageView(img); button.fontProperty().addListener((observable, oldvalue, newValue) -> calculateNewDimensions()); final Label label = new Label(button.getText()); label.onMouseClickedProperty().bind(button.onActionProperty()); imageView.onMouseReleasedProperty().bind(button.onActionProperty()); button.textProperty().addListener((observable, oldValue, newValue) -> calculateNewDimensions()); StackPane stack = new StackPane(); stack.getChildren().addAll(imageView, label); Group group = new Group(stack); group.setManaged(false); getChildren().add(group); }