public void start(Stage primaryStage) throws Exception { //Essa parte foi para apenas escrever algo no arquivo de disciplinas, para testar. //se a parte disciplina aptas da GUI estava certa. //Disciplina dis = new Disciplina("�lgebra ", 23); //DisciplinaController.getInstance().cadastrarDisciplina(dis); //......................... primaryStage.setTitle("Cadastro de Professores"); pane = FXMLLoader.load(this.getClass().getResource("cadastroProfessorFXML.fxml")); menu = (MenuButton) pane.getChildren().get(8); adiciona(); primaryStage.setScene(new Scene(pane)); primaryStage.setResizable(false); primaryStage.show(); }
@Override protected List<Labeled> getConstructorPage() { List<Labeled> list = new ArrayList<Labeled>(); MenuButton default_button = new MenuButton(DEFAULT_BUTTON); defaultLayout.apply(default_button); if (!default_button.getText().equals(DEFAULT_BUTTON)) { reportGetterFailure("new MenuButton(DEFAULT_LABEL)"); } else { list.add(default_button); } Rectangle rectangle = new Rectangle(10, 10, Color.rgb(200, 100, 100)); MenuButton graphic_button = new MenuButton(GRAPHICS_BUTTON, rectangle); defaultLayout.apply(graphic_button); if (!graphic_button.getText().equals(GRAPHICS_BUTTON) || graphic_button.getGraphic() != rectangle) { reportGetterFailure("new MenuButton(GRAPHICS_LABEL, rectangle)"); } else { list.add(graphic_button); } return list; }
public static void setUpVars() throws Exception { scene = Root.ROOT.lookup().wrap(); sceneAsParent = scene.as(Parent.class, Node.class); object = container = (MenuButtonWrap) sceneAsParent.lookup(new LookupCriteria<Node>() { public boolean check(Node cntrl) { return MenuButton.class.isAssignableFrom(cntrl.getClass()); } }).wrap(); contentPane = sceneAsParent.lookup(new ByID<Node>(MenuButtonApp.TEST_PANE_ID)).wrap(); clearBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.CLEAR_BTN_ID)).wrap(); resetBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.RESET_BTN_ID)).wrap(); addPosBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.ADD_SINGLE_AT_POS_BTN_ID)).wrap(); removePosBtn = sceneAsParent.lookup(new ByText(MenuButtonApp.REMOVE_SINGLE_AT_POS_BTN_ID)).wrap(); check = (Wrap<? extends Label>) sceneAsParent.lookup(new ByID(MenuButtonApp.LAST_SELECTED_ID)).wrap(); sideCB = sceneAsParent.lookup(ChoiceBox.class).wrap(); menuButtonAsStringMenuOwner = container.as(StringMenuOwner.class, Menu.class); menuButtonAsParent = container.as(Parent.class, MenuItem.class); }
/** * Sleeps are applied in this method, because of RT-28683. We need to wait, * until a popup is really shown, but cannot determine that, in JFX. */ private void expand(final Menu menu) { if (!MenuWrap.isShowing(menu, getEnvironment())) { final Menu parent = getParentMenu(menu); if (parent != null) { expand(parent); getEnvironment().getTimeout(BEFORE_CLICK_TO_EXPAND_SLEEP).sleep(); waitState(() -> MenuWrap.isParentShown(menu, getEnvironment()), true); } Wrap<? extends Node> mWrap = findWrap(menu); if (mWrap.getControl() instanceof MenuButton) { mWrap.mouse().move(); getEnvironment().getTimeout(BEFORE_CLICK_TO_EXPAND_SLEEP).sleep(); if (!MenuWrap.isShowing(menu, getEnvironment())) { mWrap.mouse().click(); } } else { mWrap.mouse().move(); getEnvironment().getTimeout(BEFORE_CLICK_TO_EXPAND_SLEEP).sleep(); } } }
@Override public void start(final Stage stage) { final MenuButton button1 = new MenuButton("Plain Button", null, new MenuItem("Item 1"), new MenuItem("Item 2")); button1.getStyleClass().add("action_button"); final MenuItem item = new MenuItem("Action Button Item"); item.getStyleClass().add("action_button_item"); final MenuButton button2 = new MenuButton("Dark Button", null, item, new MenuItem("Plain Item")); button2.setStyle(JFXUtil.shadedStyle(new WidgetColor(100, 0, 0))); button2.setTextFill(Color.YELLOW); button2.getStyleClass().add("action_button"); final HBox box = new HBox(button1, button2); final Scene scene = new Scene(box, 800, 700); // XXX Enable scenic view to debug styles // ScenicView.show(scene); JFXRepresentation.setSceneStyle(scene); stage.setScene(scene); stage.setTitle("MenuButtons"); stage.show(); }
@Override public void start(Stage stage) throws Exception { Group root = new Group(); MenuButton btnList = new MenuButton(); MenuItem item = new MenuItem("Testing"); item.getStyleClass().add("myMenuItem"); btnList.getItems().add(item); root.getChildren().add(btnList); Scene scene = new Scene(root, 500, 500, Color.LINEN); stage.setWidth(500); stage.setHeight(500); stage.setTitle("JavaFx Custom CSS For MenuItem Demo"); stage.setScene(scene); stage.show(); }
/** * Constructor. This will prepare the buttons, which can then be retrieved * with {@link #getBackButton()}, {@link #getForwardButton()} and * {@link #getMenuButton()}. * * @param viewer * The viewer to which the buttons will belong */ public NavigationButtons(TimeGraphWidget viewer) { List<NavigationMode> navModes = NAVIGATION_MODES; NavigationMode initialMode = navModes.get(0); BackButton backButton = new BackButton(viewer, initialMode); ForwardButton forwardButton = new ForwardButton(viewer, initialMode); MenuButton menuButton = new MenuButton(); ToggleGroup tg = new ToggleGroup(); List<RadioMenuItem> items = NAVIGATION_MODES.stream() .map(nm -> { RadioMenuItem item = new RadioMenuItem(); item.setText(nm.getModeName()); item.setGraphic(new HBox(new ImageView(nm.getBackIcon()), new ImageView(nm.getForwardIcon()))); item.setToggleGroup(tg); item.setOnAction(e -> { backButton.setNavMode(nm); forwardButton.setNavMode(nm); }); item.setDisable(!nm.isEnabled()); return item; }) .collect(Collectors.toList()); items.get(0).setSelected(true); menuButton.getItems().addAll(items); fBackButton = backButton; fForwardButton = forwardButton; fMenuButton = menuButton; }
private void createToolBars(ToolBarPanel toolBarPanel) { VLToolBar infoToolBar = new VLToolBar(); infoButton = new MenuButton(null, FXUIUtils.getIcon("info")); infoButton.setDisable(true); infoToolBar.add(infoButton); toolBarPanel.add(infoToolBar); VLToolBar clipboardToolBar = new VLToolBar(); cutButton = FXUIUtils.createButton("cut", "Remove selected text and copy to clipboard"); cutButton.setOnAction((event) -> cut()); clipboardToolBar.add(cutButton); copyButton = FXUIUtils.createButton("copy", "Copy selected text to clipboard"); copyButton.setOnAction((event) -> copy()); clipboardToolBar.add(copyButton); pasteButton = FXUIUtils.createButton("paste", "Paste text from clipboard"); pasteButton.setOnAction((event) -> paste()); clipboardToolBar.add(pasteButton); toolBarPanel.add(clipboardToolBar); VLToolBar redoToolBar = new VLToolBar(); undoButton = FXUIUtils.createButton("undo", "Undo last action"); undoButton.setOnAction((event) -> editorExecuteProc("undo")); redoToolBar.add(undoButton); redoButton = FXUIUtils.createButton("redo", "Redo last undone action"); redoButton.setOnAction((event) -> editorExecuteProc("redo")); redoToolBar.add(redoButton); toolBarPanel.add(redoToolBar); VLToolBar searchToolBar = new VLToolBar(); Button search = FXUIUtils.createButton("search", "Search for a pattern", true); search.setOnAction((event) -> editorExecuteProc("find")); searchToolBar.add(search); Button replace = FXUIUtils.createButton("replace", "Search for a pattern and replace", true); replace.setOnAction((event) -> editorExecuteProc("replace")); searchToolBar.add(replace); toolBarPanel.add(searchToolBar); VLToolBar settingsToolBar = new VLToolBar(); Button settingsButton = FXUIUtils.createButton("settings", "Modify editor settings", true); settingsButton.setOnAction((event) -> onSettings()); settingsToolBar.add(settingsButton); toolBarPanel.add(settingsToolBar); }
public void start (Stage primaryStage) throws Exception{ window = primaryStage; window.setTitle("Remover Disciplina"); pane = FXMLLoader.load(this.getClass().getResource("removerDisciplinaFXML.fxml")); TextArea texto = (TextArea) pane.getChildren().get(4); menu2 = (MenuButton) pane.getChildren().get(9); nome = (TextField) pane.getChildren().get(2); id = (TextField) pane.getChildren().get(7); adiciona(); texto.setEditable(false); window.setScene(new Scene(pane)); window.setResizable(false); window.show(); }
public void start(Stage primaryStage) throws IOException { window = primaryStage; window.setTitle("Atualiza��o de Professor"); window.setResizable(false); Pane pane = FXMLLoader.load(this.getClass().getResource("atualizarDisciplinaFXML.fxml")); menu2 = (MenuButton)pane.getChildren().get(10); id = (TextField)pane.getChildren().get(2); nome = (TextField)pane.getChildren().get(6); adiciona(); window.setScene(new Scene(pane)); window.show(); }
public void start(Stage primaryStage) throws IOException { window = primaryStage; window.setTitle("Atualiza��o de Professor"); window.setResizable(false); pane = FXMLLoader.load(this.getClass().getResource("AtualizarProfessorFXML.fxml")); menu1 = (MenuButton)pane.getChildren().get(10); menu2 = (MenuButton)pane.getChildren().get(11); adiciona(); window.setScene(new Scene(pane)); window.show(); }
public void start (Stage primaryStage) throws Exception{ window = primaryStage; window.setTitle("Procurar Professor"); pane = FXMLLoader.load(this.getClass().getResource("procurarDisciplinaFXML.fxml")); TextArea texto = (TextArea) pane.getChildren().get(4); menu2 = (MenuButton) pane.getChildren().get(9); um = (TextField) pane.getChildren().get(2); dois = (TextField) pane.getChildren().get(6); adiciona(); texto.setEditable(false); window.setScene(new Scene(pane)); window.setResizable(false); window.show(); }
@Override protected Scene getScene() { return new LabeledsApp.LabeledScene() { @Override protected Labeled getTestedLabeled() { return new MenuButton(); } }; }
protected void show() { new GetAction() { @Override public void run(Object... parameters) { ((MenuButton) container.getControl()).show(); } }.dispatch(Root.ROOT.getEnvironment()); }
protected void hide() { new GetAction() { @Override public void run(Object... parameters) { ((MenuButton) container.getControl()).hide(); } }.dispatch(Root.ROOT.getEnvironment()); }
protected boolean isShown() { return new GetAction<Boolean>() { @Override public void run(Object... parameters) { setResult(((MenuButton) container.getControl()).isShowing()); } }.dispatch(Root.ROOT.getEnvironment()); }
protected void checkShown(final boolean shown) { container.waitState(new State() { public Object reached() { return ((((MenuButton) container.getControl()).isShowing() == shown) ? Boolean.TRUE : null); } }); }
@Test public void testGetMenuButtonAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(MenuButton.class); assertThat(adjuster, is(instanceOf(ControlAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Control.class))); }
public MenuLabeledImpl(MenuButton b) { super(b); button = b; addEventHandler(ActionEvent.ACTION, e -> { button.fireEvent(new ActionEvent()); e.consume(); }); }
public static MenuItem getMenuItem(String menuSelector, String id) { MenuButton menu = (MenuButton) window.getScene().lookup(menuSelector); for (MenuItem mi : menu.getItems()) if (mi.getId().equals(id)) return mi; System.out.println("NOP"); return null; }
public AquaMenuButtonSkin(MenuButton menuButton) { super(menuButton); registerChangeListener(menuButton.focusedProperty(), "FOCUSED"); if (getSkinnable().isFocused()) { setFocusBorder(); } else { setDropShadow(); } }
public CalendarSelectorSkin(CalendarSelector selector) { super(selector); buttonIcon = new Rectangle(12, 12); button = new MenuButton(); button.setGraphic(buttonIcon); button.getStylesheets().add(CalendarView.class.getResource("calendar.css").toExternalForm()); //$NON-NLS-1$ getChildren().add(button); selector.calendarProperty().addListener(it -> updateButton()); selector.getCalendars().addListener( (Observable evt) -> updateMenuItems()); updateMenuItems(); updateButton(); }
private void renderAccountCard(Account account) { Pane pane = new AnchorPane(); addCssClass(pane, "account-card"); pane.setPrefHeight(70.0); pane.setMinHeight(70.0); pane.setMaxHeight(70.0); List<Node> children = pane.getChildren(); Label domainLabel = new Label(account.getDomain()); children.add(domainLabel); addCssClass(domainLabel, "domain-label"); UiCommons.assignAnchors(domainLabel, 5.0, 100.0, null, 5.0); Label usernameLabel = new Label(account.getUsername()); children.add(usernameLabel); addCssClass(usernameLabel, "username-label"); UiCommons.assignAnchors(usernameLabel, 10.0, 100.0, 15.0, 10.0); Button showButton = new Button("Show"); children.add(showButton); addCssClass(showButton, "control"); showButton.setFocusTraversable(false); showButton.setOnAction(event -> showModal(new PasswordRevealModal(), account)); UiCommons.assignAnchors(showButton, 5.0, 10.0, null, null); MenuButton accountMenu = new MenuButton("\u2699"); children.add(accountMenu); addCssClass(accountMenu, "control"); accountMenu.setFocusTraversable(false); UiCommons.assignAnchors(accountMenu, null, 10.0, 5.0, null); List<MenuItem> menuItems = accountMenu.getItems(); MenuItem updateMenuItem = new MenuItem("Update"); menuItems.add(updateMenuItem); updateMenuItem.setOnAction(event -> showModalWithReload(new SaveAccountModal(), Optional.of(account))); MenuItem deleteMenuItem = new MenuItem("Delete"); menuItems.add(deleteMenuItem); deleteMenuItem.setOnAction(event -> showModalWithReload(new DeleteAccountModal(), account)); viewPane.getChildren() .add(pane); }
@Override protected Labeled getListenable() { MenuButton button = new FireListenableButton(DEFAULT); defaultLayout.apply(button); return button; }
@Override protected Labeled getButton() { MenuButton button = new MenuButton(DEFAULT); defaultLayout.apply(button); return button; }
protected void createMenuButton() { menuButton = new MenuButton("Menu Button"); }
@Test public void pushMenu() throws InterruptedException { Parent<Node> parent = Root.ROOT.lookup().as(Parent.class, Node.class); Wrap<? extends MenuBar> bar = parent.lookup(MenuBar.class).wrap(); // Parent<Menu> barParent = bar.as(Parent.class, Menu.class); // Wrap<? extends Menu> menu1 = barParent. // lookup(new ByTextMenuItem<Menu>("menu1", StringComparePolicy.EXACT)).wrap(); // menu1.mouse().move(); // menu1.mouse().move(); // Parent<MenuItem> menu1_parent = menu1.as(Parent.class, MenuItem.class); // Wrap<? extends MenuItem> sub_menu1 = menu1_parent. // lookup(new ByTextMenuItem<MenuItem>("sub-menu1", StringComparePolicy.EXACT)).wrap(); // sub_menu1.mouse().move(); // Parent<MenuItem> sub_menu1_parent = sub_menu1.as(Parent.class, MenuItem.class); // Wrap<? extends MenuItem> sub_sub_menu1 = sub_menu1_parent.lookup(new ByTextMenuItem<MenuItem>("sub-sub-menu1", StringComparePolicy.EXACT)).wrap(); // sub_sub_menu1.mouse().click(); // Parent<MenuItem> sub_sub_menu1_parent = sub_sub_menu1.as(Parent.class, MenuItem.class); // Wrap<? extends MenuItem> item = sub_sub_menu1_parent.lookup(new ByTextMenuItem<MenuItem>("item1", StringComparePolicy.EXACT)).wrap(); // item.mouse().click(); StringMenuOwner menu_owner = bar.as(StringMenuOwner.class, MenuItem.class); //menu_owner.push("menu1", "sub-menu1", "sub-sub-menu1", "item1"); // menu_owner.menu().select(new ByTextMenuItem("menu1", StringComparePolicy.EXACT), // new ByTextMenuItem("sub-menu1", StringComparePolicy.EXACT), // new ByTextMenuItem("sub-sub-menu1", StringComparePolicy.EXACT)); Wrap<MenuItem> sub_menu1 = menu_owner.menu().select(new ByTextMenuItem("menu1", StringComparePolicy.EXACT), new ByTextMenuItem("sub-menu1", StringComparePolicy.EXACT)); StringMenuOwner sub_menu1_tree = sub_menu1.as(StringMenuOwner.class, MenuItem.class); sub_menu1_tree.push("sub-sub-menu1", "item1"); Wrap<? extends MenuButton> menu_button = parent.lookup(MenuButton.class).wrap(); StringMenuOwner button_menu_owner = menu_button.as(StringMenuOwner.class, MenuItem.class); button_menu_owner.push("menu1", "sub-menu1", "sub-sub-menu1", "item1"); button_menu_owner.push("item0"); button_menu_owner.menu().push(new MenuTextLookupCriteria("menu1"), new MenuTextLookupCriteria("sub-menu1"), new MenuTextLookupCriteria("sub-sub-menu1"), new MenuTextLookupCriteria("item1")); button_menu_owner.menu().push(new ByText("item0")); // MenuBarDock bar = new MenuBarDock(new SceneDock().asParent()); //// bar.asStringMenuOwner().push("menu2"); //// new LabeledDock(new SceneDock().asParent(), "menu2 pushed", StringComparePolicy.SUBSTRING); // bar.asStringMenuOwner().push("menu0", "item0"); // new LabeledDock(new SceneDock().asParent(), "item0 pushed", StringComparePolicy.SUBSTRING); // bar.asStringMenuOwner().push("menu1", "sub-menu1", "item1"); // new LabeledDock(new SceneDock().asParent(), "item1 pushed", StringComparePolicy.SUBSTRING); }
/** * Create a set of widgets to choose an aspect either from a preset or numbers * Also bind aspectArr to the sliders * @return the full formatted Region */ protected Region buildAspectSelector(double[] aspectArr, Procedure aspectSetter) { final MenuButton presetChooser = new MenuButton("Aspect Presets"); presetChooser.setTooltip(new Tooltip( "Set the aspect sliders based on a preset")); final String[] labels = { "Latitude:", "Longitude:", "Ctr. Meridian:" }; final Slider[] sliders = new Slider[] { new Slider(-90, 90, 0.), new Slider(-180, 180, 0.), new Slider(-180, 180, 0.) }; final Spinner<Double> spin0 = new Spinner<Double>(-90, 90, 0.); //yes, this is awkward. Java gets weird about arrays with generic types @SuppressWarnings("unchecked") final Spinner<Double>[] spinners = (Spinner<Double>[]) Array.newInstance(spin0.getClass(), 3); spinners[0] = spin0; spinners[1] = new Spinner<Double>(-180, 180, 0.); spinners[2] = new Spinner<Double>(-180, 180, 0.); for (int i = 0; i < 3; i ++) { aspectArr[i] = Math.toRadians(sliders[i].getValue()); link(sliders[i], spinners[i], i, aspectArr, Math::toRadians, aspectSetter, isChanging, suppressListeners); } setAspectByPreset("Standard", sliders, spinners); for (String preset: ASPECT_NAMES) { MenuItem m = new MenuItem(preset); m.setOnAction((event) -> { setAspectByPreset(((MenuItem) event.getSource()).getText(), sliders, spinners); for (int i = 0; i < 3; i ++) aspectArr[i] = Math.toRadians(sliders[i].getValue()); if (!suppressListeners.isSet()) aspectSetter.execute(); }); presetChooser.getItems().add(m); } final GridPane grid = new GridPane(); grid.setVgap(V_SPACE); grid.setHgap(H_SPACE); grid.getColumnConstraints().addAll( new ColumnConstraints(SPINNER_WIDTH,Control.USE_COMPUTED_SIZE,Control.USE_COMPUTED_SIZE), new ColumnConstraints(), new ColumnConstraints(SPINNER_WIDTH)); for (int i = 0; i < 3; i ++) { GridPane.setHgrow(sliders[i], Priority.ALWAYS); sliders[i].setTooltip(new Tooltip("Change the aspect of the map")); spinners[i].setTooltip(new Tooltip("Change the aspect of the map")); spinners[i].setEditable(true); grid.addRow(i, new Label(labels[i]), sliders[i], spinners[i]); } VBox all = new VBox(V_SPACE, presetChooser, grid); all.setAlignment(Pos.CENTER); all.managedProperty().bind(all.visibleProperty()); //make it hide when it is hiding return all; }
public MenuButton getMenuBtnLoadRuleList() { return menubtnLoadRuleList; }
private void configMenuButton(MenuButton button) { if (buttonId != null) { button.setId(buttonId); } if ((options & ActionOption.HIDE_BUTTON_TEXT) == 0) { button.textProperty().bindBidirectional(text); } if (description.get() != null) { final Tooltip tooltip = new Tooltip(); tooltip.textProperty().bindBidirectional(description); button.setTooltip(tooltip); } if (style.get() != null) { button.styleProperty().bindBidirectional(style); } if ((graphic.get() != null) && ((options & ActionOption.HIDE_BUTTON_GRAPHIC) == 0)) { button.graphicProperty().bindBidirectional(graphic); } if (alignment.get() != null) { button.alignmentProperty().bindBidirectional(alignment); } if (contentDisplay.get() != null) { button.contentDisplayProperty().bindBidirectional(contentDisplay); } if (graphicTextGap.get() >= 0) { button.graphicTextGapProperty().bindBidirectional(graphicTextGap); } button.visibleProperty().bindBidirectional(visible); button.managedProperty().bindBidirectional(managed); button.mnemonicParsingProperty().bindBidirectional(mnemonicParsing); button.getStyleClass().addAll(styleClass); if (bindStyleClass) { styleClass.setAll(button.getStyleClass()); Bindings.bindContentBidirectional(styleClass, button.getStyleClass()); } button.setOnAction(this); final ObservableList<MenuItem> buttonItems = button.getItems(); for (final IAction action : actions) { final MenuItem item = action.createMenuItem(); buttonItems.add(item); } }
public static void add(List<CheckMenuItem> me, MenuButton b) { CheckMenuItem[] array = me.toArray(new CheckMenuItem[me.size()]); if(b.getItems().size()>0) { b.getItems().clear(); } b.getItems().addAll(array); }
/** * Get the drop-down menu button, which allows switching between the * available navigation modes. * * @return The drop-down menu button */ public MenuButton getMenuButton() { return fMenuButton; }