Snippets Collections
private TilePane selectedTilePane;
private TilePane currentTilePane;
private ImageView selectedImageView;

void onMouseClicked(MouseEvent event) {
  this.resetTileBackgroundColor();
  this.selectedImageView = (ImageView) event.getSource();
  this.selectedTilePane = (TilePane) this.selectedImageView.getParent();
  this.selectedTilePane.setStyle("-fx-background-color:gray");

}

void onMouseEntered(MouseEvent event) {
  this.currentTilePane = (TilePane) event.getSource();
  if (!this.currentTilePane.equals(this.selectedTilePane)) {
    this.currentTilePane.setStyle("-fx-background-color:lightgray");
  }
}

void onMouseExited(MouseEvent event) {
  this.currentTilePane = (TilePane) event.getSource();
  if (!this.currentTilePane.equals(this.selectedTilePane)) {
    this.currentTilePane.setStyle("-fx-background-color:whitesmoke");
  }
}

private void resetTileBackgroundColor() {
  tilePane<XXXXX>.setStyle("-fx-background-color:whitesmoke");
}
star

Sun Nov 21 2021 10:52:15 GMT+0000 (Coordinated Universal Time)

#java #javafx

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension