本文整理汇总了Java中javafx.scene.control.MenuBar类的典型用法代码示例。如果您正苦于以下问题:Java MenuBar类的具体用法?Java MenuBar怎么用?Java MenuBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MenuBar类属于javafx.scene.control包,在下文中一共展示了MenuBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showMenuBar
import javafx.scene.control.MenuBar; //导入依赖的package包/类
/**
* show or hide the menuBar
*
* @param scene
* @param pMenuBar
*/
public void showMenuBar(Scene scene, MenuBar pMenuBar, boolean show) {
Parent sroot = scene.getRoot();
ObservableList<Node> rootChilds = null;
if (sroot instanceof VBox)
rootChilds = ((VBox) sroot).getChildren();
if (rootChilds == null)
throw new RuntimeException(
"showMenuBar can not handle scene root of type "
+ sroot.getClass().getName());
if (!show && rootChilds.contains(pMenuBar)) {
rootChilds.remove(pMenuBar);
} else if (show) {
rootChilds.add(0, pMenuBar);
}
pMenuBar.setVisible(show);
hideMenuButton
.setText(show ? I18n.get(I18n.HIDE_MENU) : I18n.get(I18n.SHOW_MENU));
}
示例2: start
import javafx.scene.control.MenuBar; //导入依赖的package包/类
@Override
public void start(Stage stage) {
stage.setTitle("Vokabeltrainer");
Scene scene = new Scene(new VBox(), 400, 350);
scene.setFill(Color.OLDLACE);
MenuBar menuBar = new MenuBar();
// --- Menu File
Menu menuFile = new Menu("Vokabeln");
MenuItem sample = new MenuItem("Sample");
sample.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
// Do stuff here
}
});
menuFile.getItems().add(sample);
// --- Menu Edit
Menu menuEdit = new Menu("Abfragemodus");
// --- Menu View
Menu menuView = new Menu("Statistik");
menuBar.getMenus().addAll(menuFile, menuEdit, menuView);
((VBox) scene.getRoot()).getChildren().addAll(menuBar);
stage.setScene(scene);
stage.show();
}
示例3: marathon_select
import javafx.scene.control.MenuBar; //导入依赖的package包/类
@Override public boolean marathon_select(String value) {
MenuBar menuBar = (MenuBar) node;
ObservableList<Menu> menus = menuBar.getMenus();
String[] items = value.split("\\>\\>");
Menu parentMenu = getParentMenu(menus, items[0]);
List<MenuItem> menuItems = new ArrayList<>();
for (int i = 1; i < items.length; i++) {
getChidernMenuItem(parentMenu, items[i], menuItems);
}
parentMenu.fire();
menuItems.stream().forEach((menu) -> {
if (menu instanceof CheckMenuItem) {
CheckMenuItem checkMenuItem = (CheckMenuItem) menu;
checkMenuItem.setSelected(!checkMenuItem.isSelected());
} else if (menu instanceof RadioMenuItem) {
RadioMenuItem radioMenuItem = (RadioMenuItem) menu;
radioMenuItem.setSelected(!isSelected());
}
menu.fire();
});
return true;
}
示例4: initialize
import javafx.scene.control.MenuBar; //导入依赖的package包/类
public void initialize() {
MenuBar menuBar = new MenuBar();
// Make same width as the stage
menuBar.prefWidthProperty().bind(primaryStage.widthProperty());
rootPane.setTop(menuBar);
// File menu - new, save, exit
Menu fileMenu = new Menu("File");
MenuItem newMenuItem = createMenuItem("New", actionEvent -> this.onNewFile());
MenuItem openMenuItem = createMenuItem("Open", actionEvent -> this.onOpenFile());
MenuItem saveMenuItem = createMenuItem("Save", actionEvent -> this.onSaveFile());
saveMenuItem.disableProperty().bind(jwkSetData.changedProperty().not());
MenuItem exitMenuItem = createMenuItem("Exit", actionEvent -> Platform.exit());
fileMenu.getItems().addAll(newMenuItem, openMenuItem, saveMenuItem,
new SeparatorMenuItem(), exitMenuItem);
menuBar.getMenus().addAll(fileMenu);
}
示例5: parseMenu
import javafx.scene.control.MenuBar; //导入依赖的package包/类
protected void parseMenu (Stage stage, MenuBar menuBar, JsonArray jsonArray) {
Platform.runLater(() -> {
for (int i = 0; i < jsonArray.size(); i++) {
//get menu entry
JsonObject entry = jsonArray.getJsonObject(i);
//get event and title
//String event = entry.getString("event");
String title = entry.getString("title");
//create new menu
Menu menu = new Menu(title);
//add sub menus
this.parseSubMenus(menu, entry.getJsonArray("submenus"));
//add menu to menu bar
menuBar.getMenus().add(menu);
}
menuBar.prefWidthProperty().bind(stage.widthProperty());
});
}
示例6: PLPToolMenuBarPanel
import javafx.scene.control.MenuBar; //导入依赖的package包/类
public PLPToolMenuBarPanel(Controller controller)
{
this.controller = controller;
MenuBar menuBar = new MenuBar();
Menu file = createFileMenu();
Menu edit = createEditMenu();
Menu view = createViewMenu();
Menu project = createProjectMenu();
Menu tools = createToolsMenu();
Menu simulation = createSimulationMenu();
Menu help = createHelpMenu();
menuBar.getMenus().addAll(file, edit, view, project, tools, simulation, help);
this.setCenter(menuBar);
}
示例7: buildLicence
import javafx.scene.control.MenuBar; //导入依赖的package包/类
public static MenuBar buildLicence() {
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
String licenseFileAsString = loadLicenseFileAsString(classLoader);
MenuItem licenseMenuItem = new MenuItem(licenseFileAsString);
Menu menu = new Menu("GazePlay");
menu.getItems().add(licenseMenuItem);
MenuBar menuBar = new MenuBar();
menuBar.getMenus().addAll(menu);
menuBar.setPrefHeight(40);
menuBar.setPrefWidth(80);
return menuBar;
}
示例8: createMenuBar
import javafx.scene.control.MenuBar; //导入依赖的package包/类
/**
* create the Menu Bar
*
* @param scene
*/
public MenuBar createMenuBar(Scene scene, com.bitplan.gui.App app) {
MenuBar lMenuBar = new MenuBar();
for (com.bitplan.gui.Menu amenu : app.getMainMenu().getSubMenus()) {
Menu menu = new Menu(i18n(amenu.getId()));
lMenuBar.getMenus().add(menu);
for (com.bitplan.gui.MenuItem amenuitem : amenu.getMenuItems()) {
MenuItem menuItem = new MenuItem(i18n(amenuitem.getId()));
menuItem.setOnAction(this);
menuItem.setId(amenuitem.getId());
menu.getItems().add(menuItem);
}
}
hideMenuButton = new Button(I18n.get(I18n.HIDE_MENU));
hideMenuButton.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
showMenuBar(scene, lMenuBar, !lMenuBar.isVisible());
}
});
return lMenuBar;
}
示例9: start
import javafx.scene.control.MenuBar; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) throws NotYetSupportException, GargoyleConnectionFailException, InstantiationException, IllegalAccessException, ClassNotFoundException {
primaryStage.setTitle("Database Exam");
CommonsSqllPan sqlPane = CommonsSqllPan.getSqlPane();
sqlPane.getStylesheets().add(SkinManager.getInstance().getSkin());
BorderPane root = new BorderPane(sqlPane);
Menu menu = new Menu("Exam");
MenuItem e = new MenuItem("exam");
e.setOnAction(System.out::println);
e.setAccelerator(new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN));
menu.getItems().add(e);
root.setTop(new MenuBar(menu));
primaryStage.setScene(new Scene(root, 1100, 700));
primaryStage.show();
// Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
// DockPane.initializeDefaultUserAgentStylesheet();
}
示例10: MnemonicsScene
import javafx.scene.control.MenuBar; //导入依赖的package包/类
public MnemonicsScene() {
super(box, 600, 400);
Utils.addBrowser(this);
final MenuBar bar = new MenuBar();
generateMenus(bar.getMenus(), 2, 2, 0);
CheckBox check = new CheckBox("setMnemonicParse()");
check.setSelected(true);
check.setId(CHECK_MENU_PARSE_ID);
check.selectedProperty().addListener(new ChangeListener<Boolean>() {
public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
setMnemocicParse((ObservableList)bar.getMenus(), t1);
}
});
box.getChildren().addAll(bar, check);
}
示例11: dnd
import javafx.scene.control.MenuBar; //导入依赖的package包/类
protected void dnd() throws InterruptedException {
sceneSource.mouse().click(1, new Point(0, 0));
Wrap from = Lookups.byID(sceneSource, ID_DRAG_SOURCE, Node.class);
Wrap to = Lookups.byID(sceneTarget, ID_DRAG_TARGET, Node.class);
Point fromPoint = from.getClickPoint();
Point toPoint = to.getClickPoint();
final Object fromControl = from.getControl();
if (fromControl instanceof MenuBar || fromControl instanceof ToolBar
|| fromControl instanceof ScrollPane || fromControl instanceof Pagination) {
fromPoint = new Point(2, 2);
}
if (fromControl instanceof TitledPane) {
fromPoint = new Point(5, 30);
}
final Object toControl = to.getControl();
if (toControl instanceof MenuBar || toControl instanceof ToolBar
|| toControl instanceof ScrollPane || toControl instanceof Pagination) {
toPoint = new Point(2, 2);
}
if (toControl instanceof TitledPane) {
toPoint = new Point(30, 30);
}
dnd(from, fromPoint, to, toPoint);
}
示例12: setUpClass
import javafx.scene.control.MenuBar; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
MenuApp.main(null);
scene = Root.ROOT.lookup().wrap();
sceneAsParent = scene.as(Parent.class, Node.class);
menuBar = (MenuBarWrap) sceneAsParent.lookup(MenuBar.class).wrap();
menu = (MenuWrap<? extends Menu>) menuBar.as(Parent.class, Menu.class).lookup().wrap();
menuAsParent = menu.as(Parent.class, MenuItem.class);
container = menuBar;
object = menu;
contentPane = sceneAsParent.lookup(new ByID<Node>(MenuApp.TEST_PANE_ID)).wrap();
clearBtn = sceneAsParent.lookup(new ByText(MenuApp.CLEAR_BTN_ID)).wrap();
resetBtn = sceneAsParent.lookup(new ByText(MenuApp.RESET_BTN_ID)).wrap();
addPosBtn = sceneAsParent.lookup(new ByText(MenuApp.ADD_SINGLE_AT_POS_BTN_ID)).wrap();
removePosBtn = sceneAsParent.lookup(new ByText(MenuApp.REMOVE_SINGLE_AT_POS_BTN_ID)).wrap();
check = (Wrap<? extends Label>) sceneAsParent.lookup(new ByID(MenuApp.LAST_SELECTED_ID)).wrap();
hidden = sceneAsParent.lookup(CheckBox.class, new ByID<CheckBox>(MenuApp.SHOWN_CHECK_ID)).wrap();
hiding = sceneAsParent.lookup(CheckBox.class, new ByID<CheckBox>(MenuApp.SHOWING_CHECK_ID)).wrap();
}
示例13: setUpClass
import javafx.scene.control.MenuBar; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception {
MenuItemApp.main(null);
scene = Root.ROOT.lookup().wrap();
sceneAsParent = scene.as(Parent.class, Node.class);
menuBar = sceneAsParent.lookup(MenuBar.class).wrap();
menuBarAsParent = menuBar.as(Parent.class, Menu.class);
menuBarLookup = menuBarAsParent.lookup(Menu.class, new LookupCriteria<Menu>() {
public boolean check(Menu control) {
return control.getParentMenu() == null;
}
});
menuAsMenuOwner = menuBar.as(MenuOwner.class, Menu.class);
contentPane = sceneAsParent.lookup(new ByID<Node>(MenuItemApp.TEST_PANE_ID)).wrap();
clearLastSelectedBtn = sceneAsParent.lookup(new ByText(MenuItemApp.LAST_PRESSED_CLEAR_BTN_ID)).wrap();
clearLastEventBtn = sceneAsParent.lookup(new ByText(MenuItemApp.LAST_EVENT_CLEAR_BTN_ID)).wrap();
disableBtn = sceneAsParent.lookup(CheckBox.class, new ByText(MenuItemApp.DISABLE_CB_ID)).wrap();
eventBtn = sceneAsParent.lookup(CheckBox.class, new ByText(MenuItemApp.EVENT_CB_ID)).wrap();
hideBtn = sceneAsParent.lookup(CheckBox.class, new ByText(MenuItemApp.HIDE_CB_ID)).wrap();
lastSelected = sceneAsParent.lookup(new ByID(MenuItemApp.LAST_PRESSED_ID)).wrap();
lastEvent = sceneAsParent.lookup(new ByID(MenuItemApp.LAST_EVENT_ID)).wrap();
}
示例14: impl_drawNode
import javafx.scene.control.MenuBar; //导入依赖的package包/类
@Override
public Node impl_drawNode() throws IOException {
Menu uplevelNode = null;
FXMLLoader fxmlLoader = new FXMLLoader(resource);
try {
uplevelNode = (Menu)fxmlLoader.load();
} catch (Exception e) {
System.out.println("message: " + e.getMessage());
reportGetterFailure("message: " + e.getMessage());
ParseTraceElement ptes[] = fxmlLoader.impl_getParseTrace();
for (ParseTraceElement pte: ptes) {
// see rt-19329
System.out.println("trace element: " + pte);
}
}
MenuBar mb = new MenuBar();
mb.getMenus().add(uplevelNode);
// debug: uplevelNode.getItems().add(new MenuItem("open!!"));
return mb;
}
示例15: 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;
}