0

Is there any way to make AnchorPane containing button and few Text to do padding while clicked on it like a button? I`m using JavaFX and CSS and this is my code. Everything works but not padding

FXML

<AnchorPane id="pane" fx:id="pane" layoutX="65.0" layoutY="68.0" prefHeight="90.0" prefWidth="309.0" onMouseClicked="#onSickleButtonClicked" stylesheets="@style.css">
  <children>
     <Text fx:id="sickleLevelLabel" layoutX="193.0" layoutY="27.0" strokeType="OUTSIDE" strokeWidth="0.0" text="1" wrappingWidth="95.13671875">
        <font>
           <Font size="24.0" />
        </font>
     </Text>
     <Button id="sickleButton" fx:id="sickleButton" disable="true" ellipsisString="" mnemonicParsing="false" opacity="0.0" prefHeight="76.0" prefWidth="298.0"  visible="false">
  </Button>
     <Text fx:id="sickleUpCostLabel" layoutX="129.0" layoutY="66.0" strokeType="OUTSIDE" strokeWidth="0.0" text="10" wrappingWidth="60.136717826128006">
        <font>
           <Font size="20.0" />
        </font>
     </Text>
     <Text fx:id="sickleIncomeLabel" layoutX="237.0" layoutY="66.0" strokeType="OUTSIDE" strokeWidth="0.0" text="2" wrappingWidth="51.749999821186066">
        <font>
           <Font size="20.0" />
        </font>
     </Text>
  </children>
</AnchorPane>

CSS

#pane{
    -fx-background-image: url(../Resources/sicklebutton.png);
    -fx-background-size: 300 80;
    -fx-background-repeat: no-repeat;
    -fx-background-color: rgba(0,0,0,0);
}
#pane:hover{
    -fx-effect:dropshadow(gaussian, rgba(0, 8, 29, 1), 10, 0, 0, 0);
    -fx-cursor: hand;
}
#pane:pressed{
    -fx-effect:dropshadow(gaussian, rgba(0, 8, 29, 1), 30, 0, 0, 0);
    -fx-padding: 5,5,5,5;  
}
#pane:disabled {
    -fx-opacity: 0.6;
}
James_D
  • 201,275
  • 16
  • 291
  • 322
Beforeu
  • 83
  • 2
  • 11
  • Why are you adding commas in padding values? Maybe it should be like ``-fx-padding: 5px`` or ``-fx-padding: 5 5 5 5`` – Phantom May 22 '18 at 10:22
  • tried that i think something is wrong with -fx-background-size: 300 80; Because i get some kind of padding conected with scaling when -fx-background-size: contains but then labels are still not padding as i wish :( – Beforeu May 22 '18 at 10:36
  • yea i mentioned that they are all with # but i couldnt paste it into the post here with #`s – Beforeu May 22 '18 at 11:23

0 Answers0