0

I am trying to accomplish two goals.

  1. Have the image transparent in regards to the text.
  2. Not have the image squish the text to the right.

      <Button fx:id="btn" layoutX="90.0" layoutY="14.0" mnemonicParsing="false" prefHeight="97.0" prefWidth="320.0" styleClass="root" text="Button">
        <graphic>
            <ImageView fitHeight="87.0" fitWidth="244.0">
                <image>
                    <Image url="@image.jpg"/>
                </image>
            </ImageView>
        </graphic>
    </Button>
    

Any help is appreciated greatly.

David Frick
  • 641
  • 1
  • 9
  • 25

2 Answers2

0

What you could do is make the Stage transparent so that everything on it would be transparent using this method: stage.initStyle(StageStyle.TRANSPARENT) Then you could set the scene to transparent as well scene.setFill(Color.TRANSPARENT). Approve this answer if this solved your issues:)

beastlyCoder
  • 2,349
  • 4
  • 25
  • 52
0

Set the contentDisplay property to ContentDisplay.CENTER. This should draw the text on top of the graphic used with the Button:

<Button fx:id="btn" contentDisplay="CENTER" ...>
    ...
</Button>
fabian
  • 80,457
  • 12
  • 86
  • 114
  • This works, but is there anyway to fade out the image using fxml? – David Frick Nov 30 '16 at 09:29
  • @FamousFrik Fade out like setting the opacity or using a appropriate `ColorAdjust` effect??? – fabian Nov 30 '16 at 09:35
  • This is a good working point and partial answer. Is there a way to just draw the image to the back, without necessarily making the text move, in this example to the center? So image in back to left, with text in center or right? – David Frick Nov 30 '16 at 09:39