本文整理汇总了Java中javafx.scene.control.MenuBar.setStyle方法的典型用法代码示例。如果您正苦于以下问题:Java MenuBar.setStyle方法的具体用法?Java MenuBar.setStyle怎么用?Java MenuBar.setStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.MenuBar
的用法示例。
在下文中一共展示了MenuBar.setStyle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMenuBarWithMenus
import javafx.scene.control.MenuBar; //导入方法依赖的package包/类
public MenuBar buildMenuBarWithMenus(HTMLEditor editor, final ReadOnlyDoubleProperty menuWidthProperty, String STYLE_CSS){
MenuBar menuBar = new MenuBar();
menuBar.setStyle(STYLE_CSS);
// Add File menu to menu bar
menuBar.getMenus().add(new FileMenuBuilder().getProduct(editor));
//Add Edit menu to menu bar
menuBar.getMenus().add(new EditMenuBuilder().getProduct(editor)) ;
//Add Insert menu to menu bar
menuBar.getMenus().add(new InsertMenuBuilder().getProduct(editor));
//Add Indent menu to menu bar
menuBar.getMenus().add(new IndentMenuBuilder().getProduct(editor));
// Add View menu to menu bar
menuBar.getMenus().add(new ViewMenuBuilder().getProduct(editor));
// bind width of menu bar to width of associated stage
menuBar.prefWidthProperty().bind(menuWidthProperty);
return menuBar;
}
示例2: initMenu
import javafx.scene.control.MenuBar; //导入方法依赖的package包/类
private MenuBar initMenu() {
MenuBar bar = new MenuBar();
bar.setPadding(new Insets(5));
bar.setStyle("-fx-background-color: #3C4346;");
Menu menuTasks = new Menu("Tasks");
Menu menuPeople = new Menu("People");
Menu menuShop = new Menu("Shop");
MenuItem itemCashRegister = new MenuItem("Cash Register");
MenuItem itemStocker = new MenuItem("Stocker");
itemCashRegister.setOnAction(e -> checkoutWindow());
itemStocker.setOnAction(e -> stockerWindow());
MenuItem itemEmployees = new MenuItem("Employees");
MenuItem itemCustomers = new MenuItem("Customers");
MenuItem itemIceCream = new MenuItem("Ice Cream");
itemIceCream.setOnAction(e -> IceCreamWindow());
itemEmployees.setOnAction(e -> employeesWindow());
itemCustomers.setOnAction(e -> customerWindow());
MenuItem itemOverview = new MenuItem("Shop Overview");
MenuItem itemEnd = new MenuItem("End Game");
itemOverview.setOnAction(e -> shopoverviewWindow());
itemEnd.setOnAction(e -> endGame());
menuTasks.getItems().addAll(itemCashRegister, itemStocker, itemIceCream);
menuPeople.getItems().addAll(itemEmployees, itemCustomers);
menuShop.getItems().addAll(itemOverview, itemEnd);
bar.getMenus().addAll(menuTasks, menuPeople, menuShop);
return bar;
}