下面列出了javafx.scene.control.SplitPane#setDividerPositions ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public Parent createContent() {
Region region1 = new Region();
Region region2 = new Region();
region1.getStyleClass().add("rounded");
//region2.getStyleClass().add("rounded");
final SplitPane splitPane = new SplitPane();
final String hidingSplitPaneCss =
getClass().getResource("HiddenSplitPane.css").toExternalForm();
splitPane.setId("hiddenSplitter");
splitPane.getItems().addAll(region1, region2);
splitPane.setDividerPositions(0.33, 0.66);
splitPane.getStylesheets().add(hidingSplitPaneCss);
return splitPane;
}
/**
* Setup primary components.
*/
private void setup() {
view.getStyleClass().add("vm-view");
list.getStyleClass().add("vm-list");
list.setItems(FXCollections.observableArrayList());
list.setCellFactory(c -> new VMCell());
list.getSelectionModel().selectedItemProperty().addListener((ob, o, n) -> {
view.setCenter(createVmDisplay(n));
});
SplitPane split = new SplitPane(list, view);
SplitPane.setResizableWithParent(list, Boolean.FALSE);
split.setDividerPositions(0.37);
setCenter(split);
// Create thread to continually update vm info (remove dead vms, add new ones)
ThreadUtil.runRepeated(UPDATE_TIME_MS, () -> {
Stage attachWindow = controller.windows().getAttachWindow();
if (attachWindow == null || attachWindow.isShowing()) {
refreshVmList();
}
});
}
public MainWindowFxml(MainWindow controller) {
controller.root = this;
this.setId("root");
BorderPane borderpane = new BorderPane();
borderpane.setTop(new ToolbarComponentFxml(controller.toolbarComponent));
this.getChildren().add(borderpane);
SplitPane splitPane = new SplitPane();
splitPane.setDividerPositions(0.2);
splitPane.getItems().add(new RequestCollectionComponentFxml(controller.requestCollectionComponent));
splitPane.getItems().add(new WorkingAreaComponentFxml(controller.workingArea));
borderpane.setCenter(splitPane);
}
@Override
public boolean marathon_select(String value) {
SplitPane splitPane = (SplitPane) getComponent();
JSONArray locations = new JSONArray(value);
double[] dividerLocations = new double[locations.length()];
for (int i = 0; i < locations.length(); i++) {
dividerLocations[i] = locations.getDouble(i);
}
splitPane.setDividerPositions(dividerLocations);
return true;
}
public SplitPaneSample() {
SplitPane sp = new SplitPane();
sp.setPrefSize(250, 250);
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);
getChildren().add(sp);
}
@Override
public void start(Stage stage) throws Exception {
TabPane tabPane = new TabPane();
Tab tab1 = new Tab();
tab1.setText("Demos");
tab1.setClosable(false);
SplitPane sp = new SplitPane();
final StackPane sp1 = new StackPane();
sp1.getChildren().add(createTreeView());
final BorderPane sp2 = new BorderPane();
sp2.setCenter(createChartPane());
sp.getItems().addAll(sp1, sp2);
sp.setDividerPositions(0.3f, 0.6f);
tab1.setContent(sp);
tabPane.getTabs().add(tab1);
Tab tab2 = new Tab();
tab2.setText("About");
tab2.setClosable(false);
WebView browser = new WebView();
WebEngine webEngine = browser.getEngine();
webEngine.load(getClass().getResource("/org/jfree/chart3d/fx/demo/about.html").toString());
tab2.setContent(browser);
tabPane.getTabs().add(tab2);
Scene scene = new Scene(tabPane, 1024, 768);
stage.setScene(scene);
stage.setTitle("Orson Charts JavaFX Demo");
stage.show();
}
private void setup() {
stage.getIcons().add(new Image(resource("icons/logo.png")));
stage.setTitle("Recaf");
menubar = new MainMenu(controller);
root = new BorderPane();
root.setTop(menubar);
navRoot = new BorderPane();
viewRoot = new BorderPane();
tabs = new ViewportTabs(controller);
SplitPane split = new SplitPane();
split.setOrientation(Orientation.HORIZONTAL);
split.getItems().addAll(navRoot, viewRoot);
split.setDividerPositions(0.333);
SplitPane.setResizableWithParent(navRoot, Boolean.FALSE);
root.setCenter(split);
viewRoot.setCenter(tabs);
// Navigation
updateWorkspaceNavigator();
Recaf.getWorkspaceSetListeners().add(w -> updateWorkspaceNavigator());
// Create scene & display the window
Scene scene = new Scene(root, 800, 600);
controller.windows().reapplyStyle(scene);
controller.config().keys().registerMainWindowKeys(controller, stage, scene);
stage.setScene(scene);
// Show update prompt
if (SelfUpdater.hasUpdate())
UpdateWindow.create(this).show(root);
}
private void setup() {
list.setCellFactory(cb -> new HistCell());
list.getSelectionModel().selectedItemProperty().addListener((ob, o, n) -> {
view.setCenter(createHistoryView(n == null ? o : n));
});
view.getStyleClass().add("hist-view");
SplitPane split = new SplitPane(list, view);
SplitPane.setResizableWithParent(list, Boolean.FALSE);
split.setDividerPositions(0.37);
setCenter(split);
}
private void setup() {
list.setCellFactory(cb -> new PluginCell());
list.getSelectionModel().selectedItemProperty().addListener((ob, o, n) -> {
view.setCenter(createPluginView(n == null ? o : n));
});
list.setItems(FXCollections.observableArrayList(PluginsManager.getInstance().plugins().values()));
view.getStyleClass().add("plugin-view");
SplitPane split = new SplitPane(list, view);
SplitPane.setResizableWithParent(list, Boolean.FALSE);
split.setDividerPositions(0.37);
setCenter(split);
}
@Override
public void start(Stage stage) throws Exception {
SplitPane split = new SplitPane(new FilePane(), new ContentPane());
split.setDividerPositions(0.2);
Scene scene = new Scene(split, 900, 600);
scene.getStylesheets().add("resources/style/style.css");
setupBinds(stage, scene);
stage.setScene(scene);
stage.setTitle("JRemapper");
stage.show();
}
private SplitPane buildSplitPane() {
SplitPane sp = new SplitPane();
sp.getItems().add(tree);
sp.getItems().add(hexPane);
sp.setDividerPositions(0.3, 0.7);
return sp;
}
private void createLayout() {
vBox.getChildren().add(crearteMainMenuBar());
// 左右切分布局------------------------
SplitPane horizontalSplitPane = new SplitPane();
horizontalSplitPane.setDividerPositions(0.5);
vBox.getChildren().add(horizontalSplitPane);
VBox.setVgrow(horizontalSplitPane, Priority.ALWAYS);
// 左右切分布局----左侧上下切分布局---------
SplitPane leftVerticalSplitPane = new SplitPane();
leftVerticalSplitPane.setDividerPositions(0.4);
horizontalSplitPane.getItems().add(leftVerticalSplitPane);
leftVerticalSplitPane.setOrientation(Orientation.VERTICAL);
// 左右切分布局----左侧上下切分布局----上布局-----
SplitPane leftTopHorizontalSplitPane = new SplitPane();
leftVerticalSplitPane.getItems().add(leftTopHorizontalSplitPane);
HBox leftTopRithtPane = new HBox();
Node orderPanelLayoutNode = orderPanelLayout.getNode();
HBox.setHgrow(orderPanelLayoutNode, Priority.ALWAYS);
ScrollPane marketDetailsScrollPane = new ScrollPane();
Node marketDetailsNode = marketDetailsLayout.getNode();
marketDetailsScrollPane.setContent(marketDetailsNode);
marketDetailsScrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
marketDetailsScrollPane.setPrefWidth(253);
marketDetailsScrollPane.setMinWidth(253);
marketDetailsScrollPane.setMaxWidth(253);
leftTopRithtPane.getChildren().addAll(marketDetailsScrollPane, orderPanelLayoutNode);
leftTopRithtPane.setMaxWidth(680);
leftTopRithtPane.setPrefWidth(680);
leftTopHorizontalSplitPane.getItems().addAll(tickLayout.getNode(), leftTopRithtPane);
SplitPane.setResizableWithParent(leftTopRithtPane, false);
// 左右切分布局----左侧上下切分布局----下布局-----
TabPane leftBootomTabPane = new TabPane();
leftVerticalSplitPane.getItems().add(leftBootomTabPane);
Tab orderTab = new Tab("定单");
leftBootomTabPane.getTabs().add(orderTab);
orderTab.setClosable(false);
orderTab.setContent(orderLayout.getNode());
Tab tradeTab = new Tab("成交");
leftBootomTabPane.getTabs().add(tradeTab);
tradeTab.setClosable(false);
tradeTab.setContent(tradeLayout.getNode());
// 左右切分布局----右侧TAB布局-------------
TabPane rightTabPane = new TabPane();
horizontalSplitPane.getItems().add(rightTabPane);
Tab portfolioInvestmentTab = new Tab("投资组合");
rightTabPane.getTabs().add(portfolioInvestmentTab);
portfolioInvestmentTab.setClosable(false);
SplitPane portfolioVerticalSplitPane = new SplitPane();
portfolioInvestmentTab.setContent(portfolioVerticalSplitPane);
portfolioVerticalSplitPane.setOrientation(Orientation.VERTICAL);
VBox.setVgrow(portfolioVerticalSplitPane, Priority.ALWAYS);
VBox portfolioVBox = new VBox();
portfolioVBox.getChildren().add(combinationLayout.getNode());
portfolioVBox.getChildren().add(accountLayout.getNode());
VBox.setVgrow(accountLayout.getNode(), Priority.ALWAYS);
portfolioVerticalSplitPane.getItems().add(portfolioVBox);
portfolioVerticalSplitPane.getItems().add(positionLayout.getNode());
Tab allContractTab = new Tab("全部合约");
allContractTab.setContent(contractLayout.getNode());
rightTabPane.getTabs().add(allContractTab);
allContractTab.setClosable(false);
// 状态栏------------------------------
vBox.getChildren().add(createStatusBar());
}
private Node createImageSection()
{
preview.setPreserveRatio(true);
preview.setManaged(false);
final Button removeImage = new Button(Messages.Remove, ImageCache.getImageView(ImageCache.class, "/icons/delete.png"));
removeImage.setTooltip(new Tooltip(Messages.RemoveImage));
removeImage.setOnAction(event ->
{
final Image image = preview.getImage();
if (image != null)
{
images.getItems().remove(image);
selectFirstImage();
}
});
final StackPane left = new StackPane(preview, removeImage);
// Image in background fills the area
preview.setX(5);
preview.setY(5);
preview.fitWidthProperty().bind(left.widthProperty());
preview.fitHeightProperty().bind(left.heightProperty());
// Remove button on top, upper right corner
StackPane.setAlignment(removeImage, Pos.TOP_RIGHT);
StackPane.setMargin(removeImage, new Insets(5));
images.setPlaceholder(new Label(Messages.NoImages));
images.setStyle("-fx-control-inner-background-alt: #f4f4f4");
images.setStyle("-fx-control-inner-background: #f4f4f4");
images.setCellFactory(param -> new ImageCell(preview));
// Show selected image in preview
preview.imageProperty().bind(images.getSelectionModel().selectedItemProperty());
// Enable button if something is selected
removeImage.disableProperty().bind(Bindings.isEmpty(images.getSelectionModel().getSelectedItems()));
VBox.setVgrow(images, Priority.ALWAYS);
final VBox right = new VBox(new Label(Messages.ImagesTitle), images);
right.setPadding(new Insets(5));
final SplitPane split = new SplitPane(left, right);
split.setDividerPositions(0.7);
return split;
}