private void changeStyleOnHover(Node node) {
   node.setOnMouseEntered(
       new EventHandler<MouseEvent>() {
         @Override
         public void handle(MouseEvent event) {
           node.setStyle("-fx-background-color: derive(#0096C9, 30%);");
         }
       });
   node.setOnMouseExited(
       new EventHandler<MouseEvent>() {
         @Override
         public void handle(MouseEvent event) {
           node.setStyle("-fx-background-color: #0096C9");
         }
       });
 }
Пример #2
0
 /**
  * @param node
  * @return
  */
 public static Tooltip create(Node node) {
   Tooltip tooltip = new Tooltip();
   node.setOnMouseEntered(
       (MouseEvent event) -> {
         Point2D p =
             node.localToScreen(
                 node.getLayoutBounds().getMaxX() / 2,
                 node.getLayoutBounds().getMaxY()
                     + 5); // I position the tooltip at bottom right of the node (see below for
         // explanation)
         tooltip.show(node, p.getX(), p.getY());
       });
   node.setOnMouseExited(
       (MouseEvent event) -> {
         tooltip.hide();
       });
   return tooltip;
 }
Пример #3
0
  /**
   * Change the style of a cursor when hovering over a node. Used by the buttons
   *
   * @param node
   */
  public void setNodeCursor(Node node) {

    node.setOnMouseEntered(event -> setCursor(Cursor.HAND));
    node.setOnMouseExited(event -> setCursor(Cursor.DEFAULT));
  }