本文整理匯總了Java中javafx.scene.control.CheckMenuItem.setId方法的典型用法代碼示例。如果您正苦於以下問題:Java CheckMenuItem.setId方法的具體用法?Java CheckMenuItem.setId怎麽用?Java CheckMenuItem.setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javafx.scene.control.CheckMenuItem
的用法示例。
在下文中一共展示了CheckMenuItem.setId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: MixedItemsMenu
import javafx.scene.control.CheckMenuItem; //導入方法依賴的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();
}
示例2: CheckItemsMenu
import javafx.scene.control.CheckMenuItem; //導入方法依賴的package包/類
public CheckItemsMenu() {
super(CHECK_ID);
setId(CHECK_ID);
for (int i = 0; i < 3; i++) {
CheckMenuItem item = new CheckMenuItem("Item " + i, new Rectangle(10, 10));
item.setId(item.getText());
getItems().add(item);
}
setEventHandlers();
}
示例3: Constructors
import javafx.scene.control.CheckMenuItem; //導入方法依賴的package包/類
public Constructors() {
super(CONSTRUCTORS_ID);
setId(CONSTRUCTORS_ID);
MenuItem void_menu_item = new MenuItem();
void_menu_item.setId(MENU_ITEM_VOID_ID);
MenuItem string_menu_item = new MenuItem(MENU_ITEM_STRING_ID);
string_menu_item.setId(MENU_ITEM_STRING_ID);
MenuItem graphics_menu_item = new MenuItem(MENU_ITEM_GRAPHICS_ID, new Rectangle(10, 10));
graphics_menu_item.setId(MENU_ITEM_GRAPHICS_ID);
CheckMenuItem void_check_menu_item = new CheckMenuItem();
void_check_menu_item.setId(CHECK_MENU_ITEM_VOID_ID);
CheckMenuItem string_check_menu_item = new CheckMenuItem(CHECK_MENU_ITEM_ID);
string_check_menu_item.setId(CHECK_MENU_ITEM_ID);
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);
RadioMenuItem string_radio_menu_item_parameterless = new RadioMenuItem();
string_radio_menu_item_parameterless.setId(RADIO_MENU_ITEM_PARAMETERLESS_ID);
RadioMenuItem string_radio_menu_item = new RadioMenuItem(RADIO_MENU_ITEM_ID);
string_radio_menu_item.setId(RADIO_MENU_ITEM_ID);
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);
CustomMenuItem void_node_menu_item = new CustomMenuItem();
HBox void_node_box = new HBox();
void_node_box.getChildren().addAll(new Rectangle(10, 10), new Label(NODE_MENU_ITEM_VOID_ID));
void_node_menu_item.setContent(void_node_box);
void_node_menu_item.setId(NODE_MENU_ITEM_VOID_ID);
HBox node_box = new HBox();
node_box.getChildren().addAll(new Rectangle(10, 10), new Label(NODE_MENU_ITEM_ID));
CustomMenuItem node_menu_item = new CustomMenuItem(node_box);
node_menu_item.setId(NODE_MENU_ITEM_ID);
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);
SeparatorMenuItem separator_menu_item = new SeparatorMenuItem();
separator_menu_item.setId(SEPARATOR_MENU_ITEM_VOID_ID);
getItems().addAll(void_menu_item, string_menu_item, graphics_menu_item,
void_check_menu_item, string_check_menu_item, graphics_check_menu_item,
string_radio_menu_item_parameterless, string_radio_menu_item, graphics_radio_menu_item,
void_node_menu_item, node_menu_item, graphics_node_menu_item,
separator_menu_item);
}
示例4: createContextMenu
import javafx.scene.control.CheckMenuItem; //導入方法依賴的package包/類
private void createContextMenu() {
final ContextMenu contextMenu = new ContextMenu();
removeTrackerMenuItem.setId(REMOVE_TRACKER);
removeTrackerMenuItem.setDisable(true);
updateTrackerMenuItem.setId(UPDATE_TRACKER);
updateTrackerMenuItem.setDisable(true);
final CheckMenuItem enableDhtMenuItem = new CheckMenuItem(ENABLE_DHT);
enableDhtMenuItem.setId(ENABLE_DHT);
enableDhtMenuItem.setSelected(true);
final CheckMenuItem enableLocalPeerDiscoveryMenuItem = new CheckMenuItem(ENABLE_LOCAL_PEER_DISCOVERY);
enableLocalPeerDiscoveryMenuItem.setId(ENABLE_LOCAL_PEER_DISCOVERY);
enableLocalPeerDiscoveryMenuItem.setSelected(true);
final CheckMenuItem enablePeerExchangeMenuItem = new CheckMenuItem(ENABLE_PEER_EXCHANGE);
enablePeerExchangeMenuItem.setId(ENABLE_PEER_EXCHANGE);
enablePeerExchangeMenuItem.setSelected(true);
contextMenu.getItems().addAll(updateTrackerMenuItem, removeTrackerMenuItem, new SeparatorMenuItem(),
addTrackerMenuItem, enableDhtMenuItem, enableLocalPeerDiscoveryMenuItem,
enablePeerExchangeMenuItem);
contextMenu.showingProperty().addListener(obs -> {
removeTrackerMenuItem.setDisable(true);
updateTrackerMenuItem.setDisable(true);
});
trackerTable.setContextMenu(contextMenu);
trackerTable.setRowFactory(table -> {
final TableRow<TrackableView> tableRow = new TrackerTableRow<>();
tableRow.setContextMenu(contextMenu);
tableRow.setOnContextMenuRequested(cme -> {
final TrackableView trackableView = tableRow.getItem();
if(trackableView == null) {
return;
}
final Collection<TrackableView> deletableTrackers = getDeletableTrackers(
trackerTable.getSelectionModel().getSelectedItems());
removeTrackerMenuItem.setDisable(deletableTrackers.isEmpty());
removeTrackerMenuItem.setText(deletableTrackers.size() > 1? REMOVE_TRACKER + "s" : REMOVE_TRACKER);
final Collection<TrackableView> updatableTrackers = getUpdatableTrackables(
trackerTable.getSelectionModel().getSelectedItems());
updateTrackerMenuItem.setDisable(updatableTrackers.isEmpty());
updateTrackerMenuItem.setText(updatableTrackers.size() > 1? UPDATE_TRACKER + "s" : UPDATE_TRACKER);
});
return tableRow;
});
}