List of usage examples for javafx.scene.control SplitPane SplitPane
public SplitPane()
From source file:Main.java
@Override public void start(Stage stage) { Group group = new Group(); Scene scene = new Scene(group); SplitPane sp = new SplitPane(); final StackPane sp1 = new StackPane(); sp1.getChildren().add(new Button("Button One")); final StackPane sp2 = new StackPane(); sp2.getChildren().add(new Button("Button Two")); final StackPane sp3 = new StackPane(); sp3.getChildren().add(new Button("Button Three")); sp.getItems().addAll(sp1, sp2, sp3); sp.setDividerPositions(0.3f, 0.6f, 0.9f); group.getChildren().add(sp);// w w w.j a v a 2 s .com stage.setTitle("Welcome to JavaFX!"); stage.setScene(scene); stage.sizeToScene(); stage.show(); }
From source file:Main.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle("Split Views"); Group root = new Group(); Scene scene = new Scene(root, 350, 250, Color.WHITE); SplitPane splitPane = new SplitPane(); splitPane.prefWidthProperty().bind(scene.widthProperty()); splitPane.prefHeightProperty().bind(scene.heightProperty()); VBox leftArea = new VBox(10); HBox rowBox = new HBox(20); final Text leftText = TextBuilder.create().text("Left ").translateX(20).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 20)).build(); rowBox.getChildren().add(leftText);/*from www . j av a 2 s .c o m*/ leftArea.getChildren().add(rowBox); leftArea.setAlignment(Pos.CENTER); SplitPane splitPane2 = new SplitPane(); splitPane2.setOrientation(Orientation.VERTICAL); splitPane2.prefWidthProperty().bind(scene.widthProperty()); splitPane2.prefHeightProperty().bind(scene.heightProperty()); HBox centerArea = new HBox(); final Text upperRight = TextBuilder.create().text("Text").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); centerArea.getChildren().add(upperRight); HBox rightArea = new HBox(); final Text lowerRight = TextBuilder.create().text("Lower Right").x(100).y(50).fill(Color.RED) .font(Font.font(null, FontWeight.BOLD, 35)).translateY(50).build(); rightArea.getChildren().add(lowerRight); splitPane2.getItems().add(centerArea); splitPane2.getItems().add(rightArea); splitPane.getItems().add(leftArea); splitPane.getItems().add(splitPane2); ObservableList<SplitPane.Divider> dividers = splitPane.getDividers(); for (int i = 0; i < dividers.size(); i++) { dividers.get(i).setPosition((i + 1.0) / 3); } HBox hbox = new HBox(); hbox.getChildren().add(splitPane); root.getChildren().add(hbox); primaryStage.setScene(scene); primaryStage.show(); }
From source file:com.cdd.bao.editor.endpoint.BrowseEndpoint.java
public BrowseEndpoint(Stage stage) { this.stage = stage; stage.setTitle("BioAssay Schema Browser"); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true);/* www . j a v a 2 s.c om*/ treeView.setCellFactory(p -> new BrowseTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldval, newval) -> { changeValue(newval.getValue()); }); display = new DisplaySchema(); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(display); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); Scene scene = new Scene(root, 700, 600, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item new Thread(() -> backgroundLoadTemplates()).start(); }
From source file:be.makercafe.apps.makerbench.Main.java
@Override public void start(Stage primaryStage) { setupWorkspace();//from ww w . j a va 2 s. c o m rootContextMenu = createViewerContextMenu(); viewer = createViewer(); this.stage = primaryStage; BorderPane p = new BorderPane(); p.setTop(createMenuBar()); // p.setLeft(viewer); tabFolder = new TabPane(); BorderPane bodyPane = new BorderPane(); TextArea taConsole = new TextArea(); taConsole.setPrefSize(Double.MAX_VALUE, 200.0); taConsole.setEditable(false); Console console = new Console(taConsole); PrintStream ps = new PrintStream(console, true); System.setOut(ps); System.setErr(ps); bodyPane.setBottom(taConsole); bodyPane.setCenter(tabFolder); SplitPane splitpane = new SplitPane(); splitpane.getItems().addAll(viewer, bodyPane); splitpane.setDividerPositions(0.0f, 1.0f); p.setCenter(splitpane); Scene scene = new Scene(p, 1024, 800); //scene.getStylesheets().add(this.getClass().getResource("/styles/java-keywords.css").toExternalForm()); primaryStage.setResizable(true); primaryStage.setTitle("Makerbench"); primaryStage.setScene(scene); //primaryStage.getIcons().add(new Image("/path/to/stackoverflow.jpg")); primaryStage.show(); }
From source file:eu.over9000.skadi.ui.MainWindow.java
@Override public void start(final Stage stage) throws Exception { this.stage = stage; this.detailPane = new ChannelDetailPane(this); this.bp = new BorderPane(); this.sp = new SplitPane(); this.sb = new StatusBar(); this.setupTable(); this.setupToolbar(stage); this.sp.getItems().add(this.table); this.bp.setTop(this.tb); this.bp.setCenter(this.sp); this.bp.setBottom(this.sb); final Scene scene = new Scene(this.bp, 1280, 720); scene.getStylesheets().add(this.getClass().getResource("/styles/copyable-label.css").toExternalForm()); scene.setOnDragOver(event -> {// w w w . j av a 2s . com final Dragboard d = event.getDragboard(); if (d.hasUrl() || d.hasString()) { event.acceptTransferModes(TransferMode.COPY); } else { event.consume(); } }); scene.setOnDragDropped(event -> { final Dragboard d = event.getDragboard(); boolean success = false; if (d.hasUrl()) { final String user = StringUtil.extractUsernameFromURL(d.getUrl()); if (user != null) { success = this.channelHandler.addChannel(user, this.sb); } else { this.sb.setText("dragged url is no twitch stream"); } } else if (d.hasString()) { success = this.channelHandler.addChannel(d.getString(), this.sb); } event.setDropCompleted(success); event.consume(); }); stage.setTitle("Skadi"); stage.getIcons().add(new Image(this.getClass().getResourceAsStream("/icons/skadi.png"))); stage.setScene(scene); stage.show(); stage.iconifiedProperty().addListener((obs, oldV, newV) -> { if (this.currentState.isMinimizeToTray()) { if (newV) { stage.hide(); } } }); stage.setOnCloseRequest(event -> Platform.exit()); this.bindColumnWidths(); }
From source file:com.cdd.bao.editor.EditSchema.java
public EditSchema(Stage stage) { this.stage = stage; if (MainApplication.icon != null) stage.getIcons().add(MainApplication.icon); menuBar = new MenuBar(); menuBar.setUseSystemMenuBar(true);//w w w . j a v a 2 s . c o m menuBar.getMenus().add(menuFile = new Menu("_File")); menuBar.getMenus().add(menuEdit = new Menu("_Edit")); menuBar.getMenus().add(menuValue = new Menu("_Value")); menuBar.getMenus().add(menuView = new Menu("Vie_w")); createMenuItems(); treeRoot = new TreeItem<>(new Branch(this)); treeView = new TreeView<>(treeRoot); treeView.setEditable(true); treeView.setCellFactory(p -> new HierarchyTreeCell()); treeView.getSelectionModel().selectedItemProperty().addListener((observable, oldVal, newVal) -> { if (oldVal != null) pullDetail(oldVal); if (newVal != null) pushDetail(newVal); }); treeView.focusedProperty() .addListener((val, oldValue, newValue) -> Platform.runLater(() -> maybeUpdateTree())); detail = new DetailPane(this); StackPane sp1 = new StackPane(), sp2 = new StackPane(); sp1.getChildren().add(treeView); sp2.getChildren().add(detail); splitter = new SplitPane(); splitter.setOrientation(Orientation.HORIZONTAL); splitter.getItems().addAll(sp1, sp2); splitter.setDividerPositions(0.4, 1.0); progBar = new ProgressBar(); progBar.setMaxWidth(Double.MAX_VALUE); root = new BorderPane(); root.setTop(menuBar); root.setCenter(splitter); root.setBottom(progBar); BorderPane.setMargin(progBar, new Insets(2, 2, 2, 2)); Scene scene = new Scene(root, 1000, 800, Color.WHITE); stage.setScene(scene); treeView.setShowRoot(false); treeRoot.getChildren().add(treeTemplate = new TreeItem<>(new Branch(this, "Template"))); treeRoot.getChildren().add(treeAssays = new TreeItem<>(new Branch(this, "Assays"))); treeTemplate.setExpanded(true); treeAssays.setExpanded(true); rebuildTree(); Platform.runLater(() -> treeView.getFocusModel().focus(treeView.getSelectionModel().getSelectedIndex())); // for some reason it defaults to not the first item stage.setOnCloseRequest(event -> { if (!confirmClose()) event.consume(); }); updateTitle(); // loading begins in a background thread, and is updated with a status bar Vocabulary.Listener listener = new Vocabulary.Listener() { public void vocabLoadingProgress(Vocabulary vocab, float progress) { Platform.runLater(() -> { progBar.setProgress(progress); if (vocab.isLoaded()) root.getChildren().remove(progBar); }); } public void vocabLoadingException(Exception ex) { ex.printStackTrace(); } }; Vocabulary.globalInstance(listener); }
From source file:cz.lbenda.dataman.rc.DatamanApp.java
public void prepareMainPane() { mainPane = new BorderPane(); mainPane.setId("mainPane"); mainPane.setMaxHeight(-1);/*from www . ja va2 s . c o m*/ mainPane.setMaxWidth(-1); mainPane.setMinHeight(-1); mainPane.setMinWidth(-1); mainPane.setPrefHeight(800.0); mainPane.setPrefWidth(1024.0); mainPane.getStyleClass().add("background"); mainPane.setBottom(statusBar); mainPane.setTop(ribbon); SplitPane spHorizontal = new SplitPane(); spHorizontal.setOrientation(Orientation.HORIZONTAL); SplitPane spVertical = new SplitPane(); spVertical.setOrientation(Orientation.VERTICAL); spHorizontal.getItems().addAll(leftPane, spVertical, rightPane); spHorizontal.setDividerPositions(0.1f, 0.8f, 0.1f); spVertical.getItems().addAll(centerPane, detailTabs); spVertical.setDividerPositions(0.8f, 0.2f); mainPane.setCenter(spHorizontal); centerPane.getChildren().add(centerTabs); centerTabs.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { Node n = newValue.getContent(); if (n instanceof DataTableView) { tableViewObjectProperty.setValue((DataTableView) n); sqlQueryRowsObjectProperty.setValue(((DataTableView) n).getSqlQueryRows()); } else { tableViewObjectProperty.setValue(null); sqlQueryRowsObjectProperty.setValue(null); } }); detailTabs.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> { Node n = newValue.getContent(); if (n instanceof DataTableView) { sqlQueryRowsObjectProperty.setValue(((DataTableView) n).getSqlQueryRows()); } else { sqlQueryRowsObjectProperty.setValue(null); } }); }
From source file:org.yccheok.jstock.gui.news.StockNewsJFrame.java
private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setAlwaysOnTop(true);//from w w w . j ava2s. c om setAutoRequestFocus(false); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosed(java.awt.event.WindowEvent evt) { } public void windowClosing(java.awt.event.WindowEvent evt) { NewsTask task = StockNewsJFrame.this.newsTask; if (task != null) { task.cancel(true); } } public void windowDeiconified(java.awt.event.WindowEvent evt) { } public void windowIconified(java.awt.event.WindowEvent evt) { } }); Platform.runLater(new Runnable() { @Override public void run() { // JFXPanel => Scene => SplitPane: // Left (news List) => StackPane => ListView / ProgressIndicator // Right (HTML content) => TabPane => Tab => StackPane => WebView / ProgressBar splitPane = new SplitPane(); scene = new Scene(splitPane); scene.getStylesheets() .add(StockNewsJFrame.class.getResource("StockNewsJFrame.css").toExternalForm()); jfxPanel.setScene(scene); // Left component: News List messages_o = FXCollections.observableArrayList(); newsListView = new ListView<>(messages_o); newsListView.setId("news-listview"); stackPane.setId("parent-stackPane"); stackPane.getChildren().addAll(newsListView, progressIn); splitPane.getItems().add(stackPane); SplitPane.setResizableWithParent(stackPane, Boolean.FALSE); // show progress indicator when loading progressIn.setMaxWidth(100); progressIn.setMaxHeight(100); progressIn.setVisible(true); newsListView.setVisible(true); newsListView.setCellFactory(new Callback<ListView<FeedItem>, ListCell<FeedItem>>() { @Override public ListCell<FeedItem> call(ListView<FeedItem> list) { return new DisplayNewsCard(); } }); // register event listener: add tab for news HTML content newsListView.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() >= 1) { final FeedItem msg = newsListView.getSelectionModel().getSelectedItem(); if (msg == null) { return; } final URL link = msg.getLink(); if (link == null || link.getHost() == null) { return; } if (stockNewsContent == null) { stackPane.setPrefWidth(stackPane.getWidth()); stackPane.setMaxWidth(stackPane.getWidth()); stackPane.setMinWidth(stackPane.getWidth() / 5); try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { // resize JFrame first StockNewsJFrame.this.setSize(fullSize.width, fullSize.height); java.awt.Insets in = StockNewsJFrame.this.getInsets(); jfxPanel.setSize(StockNewsJFrame.this.getWidth() - in.left - in.right, jfxPanel.getHeight()); java.awt.Insets in2 = jfxPanel.getInsets(); // calculate width & height, but not resize in AWT event dispatching thread // javafx.scene.control.SplitPane should only be accessed from JavaFX Application Thread splitPaneWidth = jfxPanel.getWidth() - in2.left - in2.right; splitPaneHeight = jfxPanel.getHeight() - in2.top - in2.bottom; } }); } catch (InterruptedException | InvocationTargetException ex) { log.error(null, ex); } // resize to full screen size of jfxPanel splitPane.resize(splitPaneWidth, splitPaneHeight); stockNewsContent = new StockNewsContent(); splitPane.getItems().add(stockNewsContent.tabPane); splitPane.setDividerPositions(0.5f); stockNewsContent.tabPane.getSelectionModel().selectedItemProperty() .addListener(new ChangeListener<Tab>() { @Override public void changed(ObservableValue<? extends Tab> observable, Tab oldTab, Tab newTab) { int i = stockNewsContent.tabPane.getSelectionModel() .getSelectedIndex(); if (i < 0) { return; } jFrameTitle = stockNewsContent.tabsInfo.get(i).second; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { StockNewsJFrame.this.setTitle(jFrameTitle); } }); } }); } stockNewsContent.addNewsTab(link, StringEscapeUtils.unescapeHtml(msg.getTitle())); } } }); retrieveNewsInBackground(); } }); this.add(jfxPanel, BorderLayout.CENTER); this.setVisible(true); }
From source file:acmi.l2.clientmod.xdat.Controller.java
private Tab createTab(Field listField) { Tab tab = new Tab(listField.getName()); SplitPane pane = new SplitPane(); TextField filter = TextFields.createClearableTextField(); VBox.setMargin(filter, new Insets(2)); TreeView<Object> elements = createTreeView(listField, filter.textProperty()); VBox.setVgrow(elements, Priority.ALWAYS); PropertySheet properties = createPropertySheet(elements); pane.getItems().addAll(new VBox(filter, elements), properties); pane.setDividerPositions(0.3);//from ww w. j ava 2s. c om tab.setContent(wrap(pane)); return tab; }