javafx.scene.control.MenuItem.getGraphic()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中javafx.scene.control.MenuItem.getGraphic()方法的一些代码示例,展示了MenuItem.getGraphic()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.getGraphic()方法的具体详情如下:
包路径:javafx.scene.control.MenuItem
类名称:MenuItem
方法名:getGraphic

暂无

代码示例

代码示例来源:origin: org.codehaus.griffon/griffon-javafx

public static void setGraphicStyle(@Nonnull MenuItem node, @Nonnull String graphicStyle) {
  requireNonNull(node, ERROR_CONTROL_NULL);
  if (isBlank(graphicStyle)) { return; }
  if (node.getGraphic() != null) {
    setStyle(node.getGraphic(), graphicStyle);
  }
}

代码示例来源:origin: org.codehaus.griffon/griffon-javafx

public static void setGraphicStyleClass(@Nonnull MenuItem node, @Nonnull String graphicStyleClass, boolean remove) {
  requireNonNull(node, ERROR_CONTROL_NULL);
  if (isBlank(graphicStyleClass) || node.getGraphic() == null) { return; }
  ObservableList<String> graphicStyleClasses = node.getGraphic().getStyleClass();
  applyStyleClass(graphicStyleClass, graphicStyleClasses, remove);
}

代码示例来源:origin: org.jfxtras/jfxtras-menu

CirclePopupMenuNode (MenuItem menuItem) {
  this.menuItem = menuItem;
  setId(this.getClass().getSimpleName() + "#" + menuNodeIdAtomicLong.incrementAndGet());
  
  // show the graphical part
  if (menuItem.getGraphic() == null) {
    throw new NullPointerException("MenuItems in CirclePopupMenu require a graphical part, text is optional");
  }
  getChildren().add(menuItem.getGraphic());
  // show the text as a tooltip
  if (menuItem.getText() != null && menuItem.getText().length() > 0) {
    Tooltip t = new Tooltip(menuItem.getText());
    Tooltip.install(this, t);
  }
  
  // react on a mouse click to perform the menu action
  setOnMouseClicked( (eventHandler) -> {
    hide();
    if (menuItem.getOnAction() != null) {
      menuItem.getOnAction().handle(null);
    }
  });
}
final private MenuItem menuItem;

代码示例来源:origin: org.jfxtras/jfxtras-menu

CornerMenuNode (MenuItem menuItem) {
  this.menuItem = menuItem;
  setId(this.getClass().getSimpleName() + "#" + menuNodeIdAtomicLong.incrementAndGet());
  
  // show the graphical part
  if (menuItem.getGraphic() == null) {
    throw new NullPointerException("MenuItems in CornerMenu require a graphical part, text is optional");
  }
  getChildren().add(menuItem.getGraphic());
  // show the text as a tooltip
  if (menuItem.getText() != null && menuItem.getText().length() > 0) {
    Tooltip t = new Tooltip(menuItem.getText());
    Tooltip.install(this, t);
  }
  
  // react on a mouse click to perform the menu action
  setOnMouseClicked( (eventHandler) -> {
    if (isAutoShowAndHide()) {
      hide();
    }
    if (menuItem.getOnAction() != null) {
      menuItem.getOnAction().handle(null);
    }
  });
}
final private MenuItem menuItem;

相关文章