12 Replies Latest reply: Jan 25, 2013 10:01 AM by David Grieve RSS

    Button with full background image

    bape_tc
      Hello,

      I want to have a button with a image as background.
      The background image has to fill the complete button background.
      If you see the screenshot (url) , there is space around the image.
      I have add a red border to see that the button size != background image.
      I also tryed style with -fx-background-repeat: repeat-x;


      [http://office.techniconsulting.be/~peeters/button.png]

      Button button = new Button();
      ImageView imageViewOn = new ImageView();
      imageViewOn.setImage(....);
      ImageView imageViewOff = new ImageView();
      imageViewOff.setImage(imageViewOff);

      button.setText(this.name);
      button.setGraphic(imageViewOff);
      button.setContentDisplay(ContentDisplay.CENTER);
      button.setStyle("-fx-border-color: red; -fx-border-width: 1;");