private ObservableList<Node> getChildren(Node node) { if (node instanceof ButtonBar) { return ((ButtonBar) node).getButtons(); } if (node instanceof ToolBar) { return ((ToolBar) node).getItems(); } if (node instanceof Pane) { return ((Pane) node).getChildren(); } if (node instanceof TabPane) { ObservableList<Node> contents = FXCollections.observableArrayList(); ObservableList<Tab> tabs = ((TabPane) node).getTabs(); for (Tab tab : tabs) { contents.add(tab.getContent()); } return contents; } return FXCollections.observableArrayList(); }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("Simple Web Server"); BorderPane root = new BorderPane(); TextArea area = new TextArea(); root.setCenter(area); ToolBar bar = new ToolBar(); Button openInBrowser = FXUIUtils.createButton("open-in-browser", "Open in External Browser", true); openInBrowser.setOnAction((event) -> { try { Desktop.getDesktop().browse(URI.create(webRoot)); } catch (IOException e) { e.printStackTrace(); } }); Button changeRoot = FXUIUtils.createButton("fldr_closed", "Change Web Root", true); changeRoot.setOnAction((event) -> { DirectoryChooser chooser = new DirectoryChooser(); File showDialog = chooser.showDialog(primaryStage); if (showDialog != null) server.setRoot(showDialog); }); bar.getItems().add(openInBrowser); bar.getItems().add(changeRoot); root.setTop(bar); System.setOut(new PrintStream(new Console(area))); System.setErr(new PrintStream(new Console(area))); area.setEditable(false); primaryStage.setScene(new Scene(root)); primaryStage.setOnShown((e) -> startServer(getParameters().getRaw())); primaryStage.show(); }
private void initCheckList() { ToolBar toolBar = new ToolBar(); toolBar.getItems().add(new Text("Check Lists")); toolBar.setMinWidth(Region.USE_PREF_SIZE); leftPane.setTop(toolBar); checkListElements = checkListInfo.getCheckListElements(); checkListView = new ListView<CheckListForm.CheckListElement>(checkListElements); checkListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { CheckListElement selectedItem = checkListView.getSelectionModel().getSelectedItem(); if (selectedItem == null) { doneButton.setDisable(true); return; } Node checkListForm = getChecklistFormNode(selectedItem, Mode.DISPLAY); if (checkListForm == null) { doneButton.setDisable(true); return; } doneButton.setDisable(false); ScrollPane sp = new ScrollPane(checkListForm); sp.setFitToWidth(true); sp.setPadding(new Insets(0, 0, 0, 10)); rightPane.setCenter(sp); }); leftPane.setCenter(checkListView); }
public GanttChart() { timelineView = new TimelineView(); timelineViewToolBar = new ToolBar(); initTimelineViewToolBar(); taskView = new TaskTableView(TASK_DATE_FORMAT); taskView.addTaskListener(this); taskViewToolBar = new ToolBar(); initTaskViewToolBar(); metadata = new GanttData(); metadata.ganttNameProperty().bind(projectName.baseTextProperty()); metadata.chartStartDateProperty().bind(dpStart.valueProperty()); metadata.chartEndDateProperty().bind(dpEnd.valueProperty()); metadata.setRoot(getGanttRoot()); saved = false; }
/** * Initializes the container which contains all the contents of the design board. */ private void initializeContainers () { this.setText(designboardProperties.getString("DesignBoardName")); this.setClosable(false); contentPane = new StackPane(); contentPane.setMinSize(width, height); scroller = new ScrollPane(); scroller.setContent(contentPane); zoomBar = new ToolBar(); container = new VBox(zoomBar, scroller); this.setContent(container); y_offset = width * RESIZE_FACTOR; x_offset = height * RESIZE_FACTOR; }
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); }
@Before @Override public void setUp() { super.setUp(); Orientation orientation = new GetAction<Orientation>() { @Override public void run(Object... os) throws Exception { setResult(((ToolBar) os[0]).getOrientation()); } }.dispatch(Root.ROOT.getEnvironment(), toolBar.getControl()); if (orientation == Orientation.VERTICAL) { verticalBtn.mouse().click(); toolBar.waitProperty(ToolBarWrap.VERTICAL_PROP_NAME, false); } }
/** override to create your own toolbar, possibly with custom icons and buttons */ protected Node createToolBar(boolean tabMode) { if(tabMode) { return null; } else { Button b = new Button("x"); FX.style(b, FxDockStyles.TOOLBAR_CLOSE_BUTTON); closeAction.attach(b); ToolBar t = new ToolBar(); FX.style(t, FxDockStyles.TOOLBAR); t.getItems().addAll(titleField, b); return t; } }
private void initControls() { this.setText(this.subject.getAbsolutePath()); ToolBar actionBar = new ToolBar(); this.saveButton = Icons.buildIconButton("Save", Icons.ICON_SAVE); this.saveButton.getStyleClass().add("small-button"); this.switchModeButton = new Button("View"); this.switchModeButton.getStyleClass().add("small-button"); this.resetButton = Icons.buildIconButton("Reload", Icons.ICON_RELOAD); this.resetButton.getStyleClass().add("small-button"); actionBar.getItems().addAll(this.saveButton, this.resetButton, this.switchModeButton); VBox.setVgrow(actionBar, Priority.NEVER); this.editorArea = new TextArea(); this.editorArea.getStyleClass().add("editor-area-monospaced"); VBox.setVgrow(this.editorArea, Priority.ALWAYS); this.formattedView = new WebView(); VBox.setVgrow(this.formattedView, Priority.ALWAYS); this.layout = new VBox(); this.layout.getChildren().addAll(actionBar); this.setContent(this.layout); this.getStyleClass().add("open-file-tab"); }
@Override public void start(Stage primaryStage) throws Exception { BorderPane pane = new BorderPane(); ToolBar toolBar = new ToolBar(); Label fileLabel = new Label("File"); flyout = createFlyout(); // Could be TOP, LEFT, RIGHT too! flyout.setFlyoutSide(Flyout.Side.BOTTOM); toolBar.getItems().addAll( fileLabel, new Separator(), flyout ); pane.setTop(toolBar); Scene scene = new Scene(pane, 600, 200); primaryStage.setScene(scene); primaryStage.show(); }
@Test public void clickOnPlus() { // Hack because javafx toolkit need to be initialized JFXPanel panel = new JFXPanel(); panel.contains(0, 0); Zoombar toolbar = new Zoombar(5, 10); ToolBar javafxBar = toolbar.getToolBar(); int initZoom = toolbar.getZoomlevel().intValue(); Button plus = (Button) javafxBar.getItems().get(0); Event.fireEvent(plus, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY, 1, true, true, true, true, true, true, true, true, true, true, null)); assertEquals(initZoom + 1, toolbar.getZoomlevel().intValue(), 1e-10); }
@Test public void clickOnMinus() { // Hack because javafx toolkit need to be initialized JFXPanel panel = new JFXPanel(); panel.contains(0, 0); Zoombar toolbar = new Zoombar(5, 10); ToolBar javafxBar = toolbar.getToolBar(); int initZoom = toolbar.getZoomlevel().intValue(); Button minus = (Button) javafxBar.getItems().get(2); Event.fireEvent(minus, new MouseEvent(MouseEvent.MOUSE_CLICKED, 0, 0, 0, 0, MouseButton.PRIMARY, 1, true, true, true, true, true, true, true, true, true, true, null)); assertEquals(initZoom - 1, toolbar.getZoomlevel().intValue(), 1e-10); }
@Test public void scrolloneUpSlider() { // Hack because javafx toolkit need to be initialized JFXPanel panel = new JFXPanel(); panel.contains(0, 0); Zoombar toolbar = new Zoombar(5, 10); ToolBar javafxBar = toolbar.getToolBar(); int initZoom = toolbar.getZoomlevel().intValue(); Slider slider = (Slider) javafxBar.getItems().get(1); slider.valueProperty().set(slider.valueProperty().get() + 1); assertEquals(initZoom + 1, toolbar.getZoomlevel().intValue(), 1e-10); }
private void showCompactToolbar(final BorderPane mainPane, final BorderPane centerPane, final ToolBar toolbar, final boolean showCompact) { final boolean isToolbarHidden = !showToolbarMenuItem.isSelected(); mainPane.setTop(showCompact || isToolbarHidden? null : toolbar); centerPane.setTop(!showCompact || isToolbarHidden? null : toolbar); toolbar.setId(showCompact? centerPane.getId() : mainPane.getId()); final Button pauseButton = toolbarButtonsMap.get(ImageUtils.PAUSE_ICON_LOCATION); final Button rssButton = toolbarButtonsMap.get(ImageUtils.RSS_ICON_LOCATION); final ObservableList<Node> toolbarButtons = toolbar.getItems(); if(showCompact) { toolbarButtons.removeAll(pauseButton, rssButton); } else if(!isExpandedToolbar(toolbar)) { //Add Pause button after Start Torrent and RSS button after Add from URL button respectively final int rssButtonIndex = toolbarButtons.indexOf(toolbarButtonsMap.get(ImageUtils.LINK_ICON_LOCATION)); toolbarButtons.add(rssButtonIndex + 1, rssButton); final int downloadButtonIndex = toolbarButtons.indexOf(toolbarButtonsMap.get(ImageUtils.DOWNLOAD_ICON_LOCATION)); toolbarButtons.add(downloadButtonIndex + 1, pauseButton); } }
/** * Instantiates a new Generator app view. * * @param action the action */ public GeneratorAppView(Action action) { // AeroFX.style(); // AquaFx.style(); tabLookup = new HashMap<>(); this.action = action; ToolBar mainBar = new ToolBar(); Label appLabel = new Label("BURST Address Generator"); mainBar.getItems().add(appLabel); tabPane = new TabPane(); ToolBar statusBar = new ToolBar(); statusBar.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT); statusBar.getItems().add(new Label("Version: 0.2.3-SNAPSHOT")); setTop(mainBar); setCenter(tabPane); setBottom(statusBar); }
public Group initialize(GameEngine gameEngine){ myRoot = new Group(); //Add behavior for menu buttons later ToolBar toolBar = new ToolBar(); Button newGameButton= new Button("New Game"); Button loadGameButton = new Button("Load Game"); Button helpButton = new Button("Help"); Image background = new Image("../LevelImages/overworld_bg.png"); ImageView bg = new ImageView(background); myRoot.getChildren().add(bg); toolBar.getItems().addAll(newGameButton, loadGameButton, helpButton); myRoot.getChildren().add(toolBar); return myRoot; }
@Override public void start(Stage primaryStage) throws Exception { final VBox root = new VBox(); final ToolBar toolbar = new ToolBar(); toolbar.getItems().add(new Button("button 1")); toolbar.getItems().add(new Button("button 2")); toolbar.getItems().add(new HorizontalSpace()); toolbar.getItems().add(new Button("button 3")); toolbar.getItems().add(new HorizontalSpace(100)); toolbar.getItems().add(new Button("button 4")); toolbar.getItems().add(new Button("button 5")); root.getChildren().add(toolbar); primaryStage.setTitle("HorizontalSpace Sample"); primaryStage.setScene(new Scene(root, 550, 100)); primaryStage.show(); }
@Override public void start(Stage primaryStage) throws Exception { final HBox root = new HBox(); final ToolBar toolbar = new ToolBar(); toolbar.setOrientation(Orientation.VERTICAL); toolbar.getItems().add(new Button("button 1")); toolbar.getItems().add(new Button("button 2")); toolbar.getItems().add(new VerticalSpace()); toolbar.getItems().add(new Button("button 3")); toolbar.getItems().add(new VerticalSpace(100)); toolbar.getItems().add(new Button("button 4")); toolbar.getItems().add(new Button("button 5")); root.getChildren().add(toolbar); primaryStage.setTitle("VerticalSpace Sample"); primaryStage.setScene(new Scene(root, 300, 300)); primaryStage.show(); }
/** * Super-constructor for all examples. */ public Example() { root = new BorderPane(); menu = new ToolBar(); canvas = new Pane(); layout = new PhysLayout(canvas); root.setCenter(canvas); root.setTop(menu); reset = new Button("Reset"); startStop = new Button("Start"); step = new Button("Step"); Button exit = new Button("Exit"); menu.getItems().addAll(startStop, step, reset, exit); startStop.setMinWidth(startStop.getWidth() + 50); exit.setOnAction((event) -> { primaryStage.close(); }); setSimulation(new Box2DSpringSimulation(layout)); }
private void createComponents() { tvLocations = new TableView<>(DataHolder.getInstance().getLocations()); tvPhotos = new TableView<>(DataHolder.getInstance().getPhotos()); laLocations = new Label("Locations"); laPhotos = new Label("Photos"); laLocations.setFont(Font.font(20)); laPhotos.setFont(Font.font(20)); btLoadKML = new Button("Load location history file(s)"); btLoadPhotos = new Button("Load image file(s)"); btLoadPhotoDirectory = new Button("Load directory"); btGeotag = new Button("Start Geotagging"); fileChooser = new FileChooser(); directoryChooser = new DirectoryChooser(); progressToolBar = new ToolBar(); progressBar = new ProgressBar(); }
public static ToolBar createGameToolBar(ToolBar toolbar){ Region spacer = new Region(); spacer.getStyleClass().setAll("spacer"); HBox buttonBar = new HBox(); buttonBar.getStyleClass().setAll("segmented-button-bar"); Button sampleButton = new Button("Tasks"); sampleButton.getStyleClass().addAll("first"); Button sampleButton2 = new Button("Administrator"); Button sampleButton3 = new Button("Search"); Button sampleButton4 = new Button("Line"); Button sampleButton5 = new Button("Process"); sampleButton5.getStyleClass().addAll("last", "capsule"); buttonBar.getChildren().addAll(sampleButton, sampleButton2, sampleButton3, sampleButton4, sampleButton5); toolbar.getItems().addAll(spacer, buttonBar); return toolbar; }
private ToolBar getToolBar() { ToolBar result = new ToolBar(); Button add = new Button("", AssetsLoader.getIcon("new_icon.png")); Button remove = new Button("", AssetsLoader.getIcon("delete_icon.png")); add.setTooltip(new Tooltip("Add a server.")); remove.setTooltip(new Tooltip("Remove current server.")); Button connect = new Button("", AssetsLoader.getIcon("connect.png")); Button disconnect = new Button("", AssetsLoader.getIcon("disconnect.png")); connect.setTooltip(new Tooltip("Connect all.")); disconnect.setTooltip(new Tooltip("Disconnect all.")); Button orgManager = new Button("", AssetsLoader.getIcon("wsp_icon.png")); orgManager.setTooltip(new Tooltip("Open organization manager.")); result.getItems().addAll(add, remove, new Separator()); result.getItems().addAll(connect, disconnect, new Separator()); result.getItems().addAll(orgManager); add.setOnAction(this::addServerAction); remove.setOnAction(this::removeServerAction); connect.setOnAction(this::connectToAllAction); disconnect.setOnAction(this::disconnectFromAll); orgManager.setOnAction(this::organizationManagerAction); cam.getNotConnectedRequiredButtons().add(remove); cam.getWspConnectionRequiredButtons().add(orgManager); return result; }
public ToolBarSample() { super(200,100); ToolBar toolbar = new ToolBar(); toolbar.getItems().add(new Button("Home")); toolbar.getItems().add(new Button("Options")); toolbar.getItems().add(new Button("Help")); getChildren().add(toolbar); }
@Override public void init() { final ToolBar toolBar = new ToolBar(); final ToolManagement toolManagement = new ToolManagement(toolBar); toolManagement.addButton("/mineIDE/img/addIcon.png"); toolManagement.addButton("/mineIDE/img/color.png"); this.addElement(toolBar); }
@Override public Void call(Object p) { if(isIgnored(p)){return null;} ToolBar c = (ToolBar) p; DnDPrepare.toolBar(c); return null; }
public ToDoView(ClientContext clientContext) { super(clientContext, Constants.TODO_CONTROLLER_NAME); //Define the layout todoList = new ListView<>(); resetButton = new Button("reset"); removeButton = new Button("remove"); ToolBar toolBar = new ToolBar(removeButton, resetButton); pane = new BorderPane(); pane.setCenter(todoList); pane.setTop(toolBar); }
public ToolbarElement() { this.toolBar = new ToolBar( new Button( "Open" ), new Separator( ), new Label( "Currently open performance report: " ), this.reportName = new Label( "None" ) ); }
@BeforeClass public static void setUpClass() throws Exception { ToolBarApp.main(null); scene = Root.ROOT.lookup().wrap(); parent = scene.as(Parent.class, Node.class); toolBar = (ToolBarWrap<? extends ToolBar>) parent.lookup(ToolBar.class).wrap(); contentPane = parent.lookup(new ByID<Node>(ToolBarApp.TEST_PANE_ID)).wrap(); toolBarAsSelectable = toolBar.as(Selectable.class, Node.class); clearBtn = parent.lookup(new ByText(ToolBarApp.CLEAR_BTN_ID)).wrap(); resetBtn = parent.lookup(new ByText(ToolBarApp.RESET_BTN_ID)).wrap(); shrinkBtn = parent.lookup(new ByText(ToolBarApp.SHRINK_BTN_ID)).wrap(); verticalBtn = parent.lookup(new ByText(ToolBarApp.VERTICAL_BTN_ID)).wrap(); lastPressedLbl = (Wrap<? extends Label>) parent.lookup(new ByID(ToolBarApp.LAST_PRESSED_LBL_ID)).wrap(); }
protected static void initBase() { mainScene = new SceneDock(new ByWindowType(Stage.class)); sceneAsParent = mainScene.asParent(); mainToolbar = new ToolBarDock(sceneAsParent, new ByID<ToolBar>("mainToolBar")); samplesTree = new TreeViewDock(sceneAsParent, new ByID<TreeView>("page-tree")); pageTreeToolbar = new ToolBarDock(sceneAsParent, new ByID<ToolBar>("page-tree-toolbar")); }
private void customize() { //TODO Customize HTMLEDITOR later. ToolBar topBar = (ToolBar) this.lookup(".top-toolbar"); ToolBar bottomBar = (ToolBar) this.lookup(".bottom-toolbar"); setupBanglaModeToggle(); setupImageInsertButton(); topBar.getItems().add(banglaModeToggle); bottomBar.getItems().add(imageInsertButton); setMdText("Hello, this is where you write :)"); }
private ToolBar makeToolbarButtons() { if (qupath == null) return null; ToolBar toolbar = new ToolBar(); toolbar.getItems().addAll( qupath.getActionToggleButton(GUIActions.MOVE_TOOL, true), qupath.getActionToggleButton(GUIActions.POINTS_TOOL, true), new Separator(Orientation.VERTICAL), qupath.getActionToggleButton(GUIActions.SHOW_ANNOTATIONS, true), qupath.getActionToggleButton(GUIActions.FILL_OBJECTS, true), qupath.getActionToggleButton(GUIActions.SHOW_GRID, true)); return toolbar; }
/** * Creates a link view pane to display in the main editor. * Sets the initial links and mode according to user selections. * * @param editor The open HTMLEditor, used to find the open buffer. * @param isAlphabetical True if alphabetical mode is enabled. * ALPHABETICAL and IN_ORDER are provided as constants * in order to make the code more readable. */ public LinkViewPane( HTMLEditor editor, boolean isAlphabetical ){ // Set up data structures for the display this.analyzer = new HTMLAnalyzer(); this.pane = new BorderPane(); this.editor = editor; this.links = new LinkedList<String>(); this.alphabeticalLinks = new HashMap<String, Integer>(); this.mode = isAlphabetical; this.scroll = new ScrollPane(); updateLinks( editor.getBuffer() ); view = new VBox(); view.setLayoutX(10); view.setSpacing(10); update(); this.toolbar = new ToolBar(); addToolBarElements(); scroll.setContent( view ); pane.setMaxHeight( 200 ); pane.setTop( toolbar ); pane.setCenter( scroll ); pane.setVisible( true ); }
private void initControls() { this.setText(this.subject.getAbsolutePath()); ToolBar actionBar = new ToolBar(); this.saveButton = Icons.buildIconButton("Save", Icons.ICON_SAVE); this.saveButton.getStyleClass().add("small-button"); this.resetButton = Icons.buildIconButton("Reload", Icons.ICON_RELOAD); this.resetButton.getStyleClass().add("small-button"); this.wordWrapCheckBox = new CheckBox("Word Wrap"); this.wordWrapCheckBox.getStyleClass().add("small-button"); this.wordWrapCheckBox.selectedProperty().set(true); actionBar.getItems().addAll(this.saveButton, this.resetButton, new HExpander(), this.wordWrapCheckBox); VBox.setVgrow(actionBar, Priority.NEVER); this.editorArea = new CodeArea(); this.editorArea.setWrapText(true); this.editorArea.setParagraphGraphicFactory(LineNumberFactory.get(this.editorArea)); this.editorArea.getStyleClass().add("editor-area-monospaced"); VBox.setVgrow(this.editorArea, Priority.ALWAYS); VBox layout = new VBox(); layout.getChildren().addAll(actionBar); layout.getChildren().add(this.editorArea); this.setContent(layout); this.getStyleClass().add("open-file-tab"); }
private VBox createTopBarsContainer(IPerspective perspective){ MenuBar menuBar = perspective.getMenuBar(); ToolBar toolBar = perspective.getToolBar(); VBox container = new VBox(); if(menuBar!= null && menuBar.getMenus().size()>0){ container.getChildren().add(menuBar); } if(toolBar != null && toolBar.getItems().size()>0){ container.getChildren().add(toolBar); } return container; }
private Node createStatsButtonBar() { weightedCheckbox = new CheckBox("gewichtet"); showTeamButton = new Button("Team"); showTeamButton.setDisable(true); showTeamButton.setOnAction(value -> new GraphView(new TeamGraphModel( teamFilter.getValue(), setTable.getItems(), fromDate.getValue(), toDate.getValue(), weightedCheckbox .isSelected()), primaryStage)); showTeamPlayerButton = new Button("Teamspieler"); showTeamPlayerButton.setDisable(true); showTeamPlayerButton.setOnAction(value -> new GraphView( new TeampPlayerGraphModel(setTable.getItems(), teamFilter .getValue(), fromDate.getValue(), toDate.getValue(), weightedCheckbox.isSelected()), primaryStage)); statisics = new Text(); showPlayerButton = new Button("Einzelspieler"); showPlayerButton.setDisable(true); showPlayerButton.setOnAction(value -> new GraphView( new PlayerGraphModel(setTable.getItems(), playerFilter .getValue(), fromDate.getValue(), toDate.getValue(), weightedCheckbox.isSelected()), primaryStage)); showPlayerPosButton = new Button("Spielerpositionen"); showPlayerPosButton.setDisable(true); showPlayerPosButton.setOnAction(value -> new GraphView( new PlayerPosGraphModel(setTable.getItems(), playerFilter .getValue(), fromDate.getValue(), toDate.getValue()), primaryStage)); ToolBar bar = new ToolBar(new Label("Statisiken: "), statisics, showTeamButton, showTeamPlayerButton, showPlayerButton, showPlayerPosButton, weightedCheckbox); bar.setBackground(Background.EMPTY); return bar; }
public SearchHandler( final GuiTaskHandler guiTaskHandler, final SessionModel model, final WordListHandler wordListHandler, final ToolBar barSearch, final CustomTextField fieldSearch, final Label labelMatches, final Button buttonCloseSearch, final Button buttonSearchUp, final Button buttonSearchDown) { this.guiTaskHandler = guiTaskHandler; this.model = model; this.wordListHandler = wordListHandler; this.barSearch = barSearch; this.fieldSearch = fieldSearch; this.labelMatches = labelMatches; this.buttonCloseSearch = buttonCloseSearch; this.buttonSearchUp = buttonSearchUp; this.buttonSearchDown = buttonSearchDown; }
/** * Create a new Toolbar. * * @param currentZoom * the current starting zoom level. * @param maxZoom * the maximal value of the zoom. */ public Zoombar(final int currentZoom, final int maxZoom) { maxzoom = maxZoom; zoomLevel = new SimpleIntegerProperty(); zoomLevel.set(currentZoom); slider = createSlider(); slider.getStyleClass().add("slider"); slider.valueProperty().addListener( (obserVal, oldVal, newVal) -> { if (oldVal.intValue() != newVal.intValue() && newVal.intValue() <= maxzoom) { zoomLevel.set(newVal.intValue()); } }); Button plus = new Button("+"); plus.getStyleClass().add("plusButton"); plus.setOnMouseClicked((event) -> { slider.setValue(slider.getValue() - slider.getMajorTickUnit()); }); Button minus = new Button("-"); minus.getStyleClass().add("minusButton"); minus.setOnMouseClicked((event) -> { slider.setValue(slider.getValue() + slider.getMajorTickUnit()); }); toolbar = new ToolBar(); toolbar.getStyleClass().add("toolbar"); toolbar.getItems().addAll(minus, slider, plus); toolbar.setOrientation(Orientation.VERTICAL); }
@Test public void scrolloneDownSlider() { // Hack because javafx toolkit need to be initialized JFXPanel panel = new JFXPanel(); panel.contains(0, 0); Zoombar toolbar = new Zoombar(5, 10); ToolBar javafxBar = toolbar.getToolBar(); int initZoom = toolbar.getZoomlevel().intValue(); Slider slider = (Slider) javafxBar.getItems().get(1); slider.valueProperty().set(slider.valueProperty().get() - 1); assertEquals(initZoom - 1, toolbar.getZoomlevel().intValue(), 1e-10); }