Javafx Removable System

This is what I like, what I saw in several different programs. I don’t know where it comes from or what it is actually called, but here is an example panel in Visual Studio.

enter image description here

Please note that I easily attach the panel with ease. Is this possible with Javafx?

+7
java javafx
source share
4 answers

I understand this question is old, but it might be interesting for others to find out. I created a lightweight JavaFX docking library for both my own and insecure applications under the LGPL license.

https://github.com/RobertBColton/DockFX

enter image description here

+3
source share

There is no built-in docking infrastructure for JavaFX 8.

There are some third-party solutions, such as Drombler FX . I have not used any of them.

A simple home system for docking and detaching panels is quite easy to create, but an integrated system will be quite complex. The following code is adapted from zonski's answer to a discussion of the docking platform in the Oracle JavaFX forum topics .

dockedundocked

import javafx.application.Application; import javafx.geometry.Orientation; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.*; public class SimpleDocking extends Application { public void start(final Stage stage) throws Exception { final SplitPane rootPane = new SplitPane(); rootPane.setOrientation(Orientation.VERTICAL); final FlowPane dockedArea = new FlowPane(); dockedArea.getChildren().add(new Label("Some docked content")); final FlowPane centerArea = new FlowPane(); final Button undockButton = new Button("Undock"); centerArea.getChildren().add(undockButton); rootPane.getItems().addAll(centerArea, dockedArea); stage.setScene(new Scene(rootPane, 300, 300)); stage.show(); final Dialog dialog = new Dialog(stage); undockButton.disableProperty().bind(dialog.showingProperty()); undockButton.setOnAction(actionEvent -> { rootPane.getItems().remove(dockedArea); dialog.setOnHidden(windowEvent -> { rootPane.getItems().add(dockedArea); }); dialog.setContent(dockedArea); dialog.show(stage); }); } private class Dialog extends Popup { private BorderPane root; private Dialog(Window parent) { root = new BorderPane(); root.setPrefSize(200, 200); root.setStyle("-fx-border-width: 1; -fx-border-color: gray"); root.setTop(buildTitleBar()); setX(parent.getX() + 50); setY(parent.getY() + 50); getContent().add(root); } public void setContent(Node content) { root.setCenter(content); } private Node buildTitleBar() { BorderPane pane = new BorderPane(); pane.setStyle("-fx-background-color: burlywood; -fx-padding: 5"); final Delta dragDelta = new Delta(); pane.setOnMousePressed(mouseEvent -> { dragDelta.x = getX() - mouseEvent.getScreenX(); dragDelta.y = getY() - mouseEvent.getScreenY(); }); pane.setOnMouseDragged(mouseEvent -> { setX(mouseEvent.getScreenX() + dragDelta.x); setY(mouseEvent.getScreenY() + dragDelta.y); }); Label title = new Label("My Dialog"); title.setStyle("-fx-text-fill: midnightblue;"); pane.setLeft(title); Button closeButton = new Button("X"); closeButton.setOnAction(actionEvent -> hide()); pane.setRight(closeButton); return pane; } } private static class Delta { double x, y; } public static void main(String[] args) throws Exception { launch(args); } } 

If you have an extensive need for such a structure, you may want to look into the platform.

+6
source share

As stated in the previous answer , JavaFX does not have built-in support for dockable tabs. There is an OpenJDK issue requesting support for drag and drop tabs.

A recent third-party solution that is worth a look is DockFX , which is under active development at the time of writing (September 2015)

0
source share

Simple docking infrastructure for JavaFX:

https://github.com/andy-goryachev/FxDock

 public void start(Stage s) throws Exception { // plug in custom windows and dockable panes. FxDockFramework.setGenerator(new DemoPanes()); // load saved layout int ct = FxDockFramework.loadLayout(); if(ct == 0) { // when no saved layout exists, open the first window DemoWindow.openBrowser("https://github.com/andy-goryachev/FxDock"); } } 
0
source share

All Articles