本文整理汇总了Java中javafx.scene.control.CustomMenuItem类的典型用法代码示例。如果您正苦于以下问题:Java CustomMenuItem类的具体用法?Java CustomMenuItem怎么用?Java CustomMenuItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CustomMenuItem类属于javafx.scene.control包,在下文中一共展示了CustomMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createHeaderPane
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public Node createHeaderPane(WeekView calView) {
final GridPane container = new GridPane();
container.setAlignment(Pos.BOTTOM_LEFT);
container.getStyleClass().add("headerpane");
final Label lblWeekday = new Label(calView.getDate().get().format(DateTimeFormatter.ofPattern("EEE")));
lblWeekday.getStyleClass().add("label-weekday");
final Label lblDate = new Label(calView.getDate().get().toString());
lblDate.getStyleClass().add("label-date");
final ContextMenu dayChooserMenu = new ContextMenu();
final CustomMenuItem item = new CustomMenuItem(new DayChooser(calView.getDate()));
dayChooserMenu.getStyleClass().add("day-chooser");
item.setHideOnClick(false);
dayChooserMenu.getItems().add(item);
lblDate.setOnMouseClicked(event ->
dayChooserMenu.show(lblDate,
lblDate.localToScreen(0, 0).getX(),
lblDate.localToScreen(0, 0).getY())
);
final Button left = new Button("<");
left.getStyleClass().add("header-button");
left.setOnAction(event -> calView.getDate().set(calView.getDate().get().minusDays(1)));
final Button right = new Button(">");
right.getStyleClass().add("header-button");
right.setOnAction(event -> calView.getDate().set(calView.getDate().get().plusDays(1)));
final ColumnConstraints columnWeekday = new ColumnConstraints(70);
final ColumnConstraints columnCenter = new ColumnConstraints(20,50,Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.LEFT,true);
final ColumnConstraints columnSwitcher = new ColumnConstraints(60);
container.getColumnConstraints().addAll(columnWeekday, columnCenter, columnSwitcher);
container.add(lblWeekday,0,0);
container.add(lblDate, 1,0);
container.add(new HBox(left, right), 2,0);
return container;
}
示例2: populatePopup
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
private void populatePopup(LinkedList<String> results) {
List<CustomMenuItem> menuItems = results.stream()
.map(Label::new)
.map(label -> {
CustomMenuItem menuItem = new CustomMenuItem(label, true);
menuItem.setOnAction(action -> {
select(label.getText());
popup.hide();
});
return menuItem;
})
.collect(Collectors.toCollection(LinkedList::new));
popup.getItems().setAll(menuItems);
if (!popup.isShowing()) {
popup.show(this, Side.BOTTOM, 0, 0);
}
}
示例3: DefaultComponentContextMenu
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public DefaultComponentContextMenu(ArmaControl c) {
MenuItem configure = new MenuItem(Lang.ApplicationBundle().getString("ContextMenu.DefaultComponent.configure"));
Counter counter = new Counter(0, 0, Integer.MAX_VALUE, 1.0, true);
counter.addUpdateButton(-10, "-10", 0);
counter.addUpdateButton(10, "+10", 100); //put on end
CustomMenuItem renderQueueItem = new CustomMenuItem(counter, false);
Menu renderQueueMenu = new Menu(Lang.ApplicationBundle().getString("ContextMenu.DefaultComponent.render_queue"), null, renderQueueItem);
getItems().addAll(/*renderQueueMenu, */configure);
configure.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
showControlPropertiesPopup(c);
}
});
}
示例4: populatePopup
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
/**
* Populate the entry set with the given search results. Display is limited to 10 entries, for performance.
*
* @param searchResult The set of matching strings.
*/
private void populatePopup(List<String> searchResult) {
List<CustomMenuItem> menuItems = new LinkedList<>();
// If you'd like more entries, modify this line.
int maxEntries = 10;
int count = Math.min(searchResult.size(), maxEntries);
for (int i = 0; i < count; i++) {
final String result = searchResult.get(i);
Label entryLabel = new Label(result);
CustomMenuItem item = new CustomMenuItem(entryLabel, true);
item.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
textInputControl.setText(result); //todo add word
entriesPopup.hide();
}
});
menuItems.add(item);
}
entriesPopup.getItems().clear();
entriesPopup.getItems().addAll(menuItems);
}
示例5: InvisibleItemsMenu
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public InvisibleItemsMenu() {
super(INVISIBLE_ID);
setId(INVISIBLE_ID);
getItems().addAll(
new MenuItem("Menu Item", new Rectangle(10, 10)),
new MenuItem("Invisible Menu Item", new Rectangle(10, 10)),
new CheckMenuItem("Check Item", new Rectangle(10, 10)),
new CheckMenuItem("Invisible Check Item", new Rectangle(10, 10)),
new RadioMenuItem("Radio Item", new Rectangle(10, 10)),
new RadioMenuItem("Invisible Radio Item", new Rectangle(10, 10)),
new CustomMenuItem(new Label("Custom Item")),
new CustomMenuItem(new Label("Invisible Custom Item")));
setEventHandlers();
}
示例6: populatePopup
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
/**
* Populate the entry set with the given search results. Display is limited to 10 entries, for performance.
* @param searchResult The set of matching strings.
*/
private void populatePopup(List<String> searchResult) {
List<CustomMenuItem> menuItems = new LinkedList<>();
// If you'd like more entries, modify this line.
int maxEntries = 10;
int count = Math.min(searchResult.size(), maxEntries);
for (int i = 0; i < count; i++)
{
final String result = searchResult.get(i);
Label entryLabel = new Label(result);
CustomMenuItem item = new CustomMenuItem(entryLabel, true);
item.setOnAction(new EventHandler<ActionEvent>()
{
@Override
public void handle(ActionEvent actionEvent) {
getEditor().setText(result);
entriesPopup.hide();
}
});
menuItems.add(item);
}
entriesPopup.getItems().clear();
entriesPopup.getItems().addAll(menuItems);
}
示例7: popularPopup
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
private void popularPopup(ObservableList<T> lista_itens) {
int maximoItens = 18;
int contador = Math.min(lista_itens.size(), maximoItens);
List<CustomMenuItem> popupItens = new LinkedList<>();
for (int i = 0; i < contador; i++) {
final T item = lista_itens.get(i);
Label itemLabel = new Label(item.toString());
CustomMenuItem menuItem = new CustomMenuItem(itemLabel, true);
menuItem.setOnAction(actionEvent -> {
setText(item.toString());
popup.hide();
if (controlador != null) {
controladorF.adicionar(null);
}
});
popupItens.add(menuItem);
}
popup.getItems().clear();
popup.getItems().addAll(popupItens);
}
示例8: populatePopup
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
/**
* Populate the entry set with the given search results. Display is limited
* to 10 entries, for performance.
*
* @param searchResult
* The set of matching strings.
*/
private void populatePopup(List<String> searchResult) {
List<CustomMenuItem> menuItems = new LinkedList<>();
// If you'd like more entries, modify this line.
int maxEntries = 10;
int count = Math.min(searchResult.size(), maxEntries);
for (int i = 0; i < count; i++) {
final String result = searchResult.get(i);
Label entryLabel = new Label(result);
CustomMenuItem item = new CustomMenuItem(entryLabel, true);
item.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
setText(result);
entriesPopup.hide();
}
});
menuItems.add(item);
}
entriesPopup.getItems().clear();
entriesPopup.getItems().addAll(menuItems);
}
示例9: createCMForStructureViewList
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public static ContextMenu createCMForStructureViewList(ListView<Actor> listView) {
ContextMenu cm = new ContextMenu();
CustomMenuItem addActorMenuItem = GUIUtil.createTooltipedMenuItem("Add new",
"Create new global Actor and add it to currently selected SisScene.\n\n"
+ aboutActor);
Menu addExistingActorMenuItem = generateAddExistingActorMenu(false);
addActorMenuItem.setOnAction((ActionEvent event) -> {
addNewActor();
});
cm.getItems().addAll(addActorMenuItem);
if (addExistingActorMenuItem.getItems().size() != 0) {
cm.getItems().add(addExistingActorMenuItem);
}
cm.autoHideProperty().set(true);
return cm;
}
示例10: getSuggestion
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
CustomMenuItem getSuggestion(String suggestion) {
Label entryLabel = new Label(suggestion);
CustomMenuItem item = new CustomMenuItem(entryLabel, true);
item.setOnAction(f -> {
addPrincipal.setText(suggestion);
});
return item;
}
示例11: createZoomMenus
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public MenuItem createZoomMenus() {
Integer zoomValue = getDefaultZoom();
R.mainStyle.fontSizeProperty().bind(DoubleExpression.doubleExpression(zoomSpinner.valueProperty()).multiply(0.13d));
zoomSpinner.getValueFactory().setValue(zoomValue.doubleValue());
Label l = new Label("Zoom", zoomSpinner);
l.setContentDisplay(ContentDisplay.RIGHT);
return new CustomMenuItem(l, false);
}
示例12: MixedItemsMenu
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public MixedItemsMenu() {
super(MIXED_ID);
setId(MIXED_ID);
MenuItem graphics_menu_item = new MenuItem(MENU_ITEM_GRAPHICS_ID, new Rectangle(10, 10));
graphics_menu_item.setId(MENU_ITEM_GRAPHICS_ID);
graphics_menu_item.setAccelerator(MENU_ITEM_ACCELERATOR);
CheckMenuItem graphics_check_menu_item = new CheckMenuItem(CHECK_MENU_ITEM_GRAPHICS_ID, new Rectangle(10, 10));
graphics_check_menu_item.setId(CHECK_MENU_ITEM_GRAPHICS_ID);
graphics_check_menu_item.setAccelerator(CHECK_MENU_ITEM_ACCELERATOR);
RadioMenuItem graphics_radio_menu_item = new RadioMenuItem(RADIO_MENU_ITEM_GRAPHICS_ID, new Rectangle(10, 10));
graphics_radio_menu_item.setId(RADIO_MENU_ITEM_GRAPHICS_ID);
graphics_radio_menu_item.setAccelerator(RADIO_MENU_ITEM_ACCELERATOR);
HBox node_box_bool = new HBox();
node_box_bool.getChildren().addAll(new Rectangle(10, 10), new Label(NODE_MENU_ITEM_BOOL_ID));
CustomMenuItem graphics_node_menu_item = new CustomMenuItem(node_box_bool, true);
graphics_node_menu_item.setId(NODE_MENU_ITEM_BOOL_ID);
graphics_node_menu_item.setAccelerator(NODE_MENU_ITEM_ACCELERATOR);
SeparatorMenuItem separator_menu_item = new SeparatorMenuItem();
separator_menu_item.setId(SEPARATOR_MENU_ITEM_VOID_ID);
getItems().addAll(graphics_menu_item,
graphics_check_menu_item,
graphics_radio_menu_item,
graphics_node_menu_item,
separator_menu_item);
setEventHandlers();
}
示例13: NodeItemsMenu
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public NodeItemsMenu() {
super(NODE_ID);
setId(NODE_ID);
for (int i = 0; i < 3; i++) {
CustomMenuItem item = new CustomMenuItem(new Label("Item " + i));
item.setId("Item " + i);
getItems().add(item);
}
setEventHandlers();
}
示例14: AllInvisibleItemsMenu
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
public AllInvisibleItemsMenu() {
super(ALL_INVISIBLE_ID);
setId(ALL_INVISIBLE_ID);
getItems().addAll(
new MenuItem("Invisible Menu Item", new Rectangle(10, 10)),
new CheckMenuItem("Invisible Check Item", new Rectangle(10, 10)),
new RadioMenuItem("Invisible Radio Item", new Rectangle(10, 10)),
new CustomMenuItem(new Label("Invisible Custom Item")));
setEventHandlers();
}
示例15: getCompletionMenuItem
import javafx.scene.control.CustomMenuItem; //导入依赖的package包/类
private MenuItem getCompletionMenuItem(final String name, final String oldText, final int startInd, final String completion, final Node graphic) {
Label label = new Label(name);
label.setMaxWidth(Double.POSITIVE_INFINITY);
CustomMenuItem item = new CustomMenuItem(label);
item.setOnAction(e -> {
currentText.set(oldText.substring(0, startInd) + completion);
textAreaInput.appendText("");
updateLastHistoryListEntry();
});
if (graphic != null) {
label.setContentDisplay(ContentDisplay.RIGHT);
label.setGraphic(graphic);
}
return item;
}