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

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

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

暂无

代码示例

代码示例来源:origin: pmd/pmd

autoCompletePopup.getItems().get(focusIdx).getOnAction().handle(new ActionEvent());

代码示例来源:origin: stackoverflow.com

private void keyPressed(KeyEvent event) {
 for (MenuItem mi : tabPane.getContextMenu().getItems())
   {
    if (mi.getAccelerator()!=null && mi.getAccelerator().match(event))
    {
      mi.getOnAction().handle(null);
      event.consume();
      return;
    }
  }
}

代码示例来源: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;

代码示例来源:origin: it.tidalwave.northernwind.rca/it-tidalwave-role-ui-javafx

menuItem.getOnAction().handle(new ActionEvent());

代码示例来源:origin: it.tidalwave.steelblue/it-tidalwave-role-ui-javafx

menuItem.getOnAction().handle(new ActionEvent());

代码示例来源:origin: no.tornado/tornadofx-controls

public Node apply(MultiSelect<E> multiSelect, E item) {
    SplitMenuButton button = new SplitMenuButton();
    button.setText(multiSelect.getConverter().toString(item));
    MenuItem remove = new MenuItem(String.format("Remove %s", item));
    remove.setOnAction(event -> {
      int index = multiSelect.getChildrenUnmodifiable().indexOf(button);
      multiSelect.getItems().remove(item);
      multiSelect.getChildrenUnmodifiable().get(index).requestFocus();
    });
    button.getItems().add(remove);
    button.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
      if (event.getCode() == KeyCode.BACK_SPACE)
        remove.getOnAction().handle(null);
    });
    return button;
  }
}

代码示例来源:origin: org.controlsfx/controlsfx

private static void unconfigure(final MenuItem menuItem) {
  if (menuItem == null || !(menuItem.getOnAction() instanceof Action)) {
    return;
  }
  Action action = (Action) menuItem.getOnAction();
  menuItem.styleProperty().unbind();
  menuItem.textProperty().unbind();
  menuItem.disableProperty().unbind();
  menuItem.acceleratorProperty().unbind();
  menuItem.graphicProperty().unbind();
  action.getProperties().removeListener(new MenuItemPropertiesMapChangeListener<>(menuItem, action));
  if (menuItem instanceof RadioMenuItem) {
    ((RadioMenuItem) menuItem).selectedProperty().unbindBidirectional(action.selectedProperty());
  } else if (menuItem instanceof CheckMenuItem) {
    ((CheckMenuItem) menuItem).selectedProperty().unbindBidirectional(action.selectedProperty());
  }
  menuItem.setOnAction(null);
}

相关文章