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

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

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

暂无

代码示例

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

/*******************************************************************************************************************
 *
 ******************************************************************************************************************/
@Test
public void must_set_the_MenuItem_text_from_UserAction_Displayable()
 throws InterruptedException
 {
  final List<MenuItem> menuItems = fixture.createMenuItems(roleMapWithUserActionProvider);
  assertThat(menuItems, is(not(nullValue())));
  assertThat(menuItems.size(), is(actions.size()));
  for (int i = 0; i < menuItems.size(); i++)
   {
    final MenuItem menuItem = menuItems.get(i);
    assertThat(menuItem, is(not(nullValue())));
    assertThat(menuItem.getText(), is("Action #" + i));
   }
 }

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

/*******************************************************************************************************************
 *
 ******************************************************************************************************************/
@Test
public void must_set_the_MenuItem_text_from_UserAction_Displayable()
 throws InterruptedException
 {
  final List<MenuItem> menuItems = fixture.createMenuItems(asObjectWithUserActionProvider);
  assertThat(menuItems, is(not(nullValue())));
  assertThat(menuItems.size(), is(actions.size()));
  for (int i = 0; i < menuItems.size(); i++)
   {
    final MenuItem menuItem = menuItems.get(i);
    assertThat(menuItem, is(not(nullValue())));
    assertThat(menuItem.getText(), is("Action #" + i));
   }
 }

代码示例来源:origin: com.uvic-cfar.swim/worldwind

/**
 * Handles action events to enable or disable selected SWIM data list
 * view items. 
 */
@Override
public void handle(ActionEvent event) {
  int index = this.listView.getSelectionModel().getSelectedIndex();
  
  if (-1 != index) {
    String identifier = this.listView.getItems().get(index);
    MenuItem menuItem = (MenuItem) event.getSource();
    
    if (menuItem.getText().equals(SwimDataListView.ENABLE)) {
      this.activate(identifier);
    } else if (menuItem.getText().equals(SwimDataListView.DISABLE)) {
      this.deactivate(identifier);
    }
    
    this.listView.worldWindow.redrawNow();
  }
}

代码示例来源:origin: com.bitplan.radolan/com.bitplan.radolan

default:
 LOGGER.log(Level.WARNING, "unhandled menu item " + menuItem.getId()
   + ":" + menuItem.getText());

相关文章