When I create a new Button in JavaFX and make the background transparent using either
myButton.setBackground(Background.EMPTY);
or myButton.setStyle("-fx-background-color: transparent;")
, the hitbox is reduced to just the text inside the button when triggering the ActionEvent with:
myButton.setOnAction(newjavafx.event.EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
//handle UI input
}
});
This means I have to carefully target a letter to click on, which can be frustrating, especially with changing or small text.
Is there a way to maintain a consistent hitbox size while still having a transparent background?