-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitPaneToggleTest.java
More file actions
66 lines (55 loc) · 1.89 KB
/
Copy pathSplitPaneToggleTest.java
File metadata and controls
66 lines (55 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package application;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.SplitPane;
import javafx.scene.control.TitledPane;
import javafx.scene.control.ToggleButton;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Duration;
public class SplitPaneToggleTest extends Application
{
@Override
public void start(Stage primaryStage)
{
ToggleButton settings = new ToggleButton("Settings");
SplitPane splitPane = new SplitPane();
TitledPane titledPane = new TitledPane("Options", new Label("An option"));
VBox settingsPane = new VBox(titledPane);
settingsPane.setMinWidth(0);
splitPane.getItems().addAll(new BorderPane(new Label("Main content")), settingsPane);
DoubleProperty splitPaneDividerPosition = splitPane.getDividers().get(0).positionProperty();
//update toggle button status if user moves divider:
splitPaneDividerPosition.addListener((obs, oldPos, newPos) -> settings.setSelected(newPos.doubleValue() < 0.95));
splitPaneDividerPosition.set(0.8);
settings.setOnAction(event -> {
KeyValue end;
if(settings.isSelected())
{
//splitPane.setDividerPositions(0.8);
end = new KeyValue(splitPaneDividerPosition, 0.8);
}
else
{
//splitPane.setDividerPositions(1.0);
end = new KeyValue(splitPaneDividerPosition, 1.0);
}
new Timeline(new KeyFrame(Duration.seconds(0.5), end)).play();
});
BorderPane root = new BorderPane(splitPane, new HBox(settings), null, null, null);
Scene scene = new Scene(root, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args)
{
launch(args);
}
}