import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.*; // javafx.scene.layout.Pane import javafx.stage.Stage; import javafx.scene.text.TextAlignment; import javafx.scene.text.Font; import javafx.geometry.Pos; import javafx.geometry.Insets; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.event.Event; public class UIBspSplitPane01 extends Application implements EventHandler{ private Button bn1 = new Button("1"); private Button bn2 = new Button("2"); private Button bn3 = new Button("3"); private Button bn4 = new Button("4"); private Button bn2_2 = new Button("2/2"); private SplitPane splitpane = null; private TextArea editor1 = new TextArea("1"); private TextArea editor2 = new TextArea("2"); private TextArea editor3 = new TextArea("3"); private TextArea editor4 = new TextArea("4"); @Override public void start(Stage stage) { BorderPane borderpane = new BorderPane(); bn1.setFont(new Font(22)); bn2.setFont(new Font(22)); bn3.setFont(new Font(22)); bn4.setFont(new Font(22)); bn2_2.setFont(new Font(22)); bn1.setOnAction(this); bn2.setOnAction(this); bn3.setOnAction(this); bn4.setOnAction(this); bn2_2.setOnAction(this); ToolBar toolBar = new ToolBar( bn1, bn2, bn3, bn4, bn2_2 ); borderpane.setTop(toolBar); editor1.setFont(new Font(22)); editor2.setFont(new Font(22)); editor3.setFont(new Font(22)); editor4.setFont(new Font(22)); splitpane = new SplitPane(); borderpane.setCenter(splitpane); setSplitPane(2); Scene scene= new Scene(borderpane, 460, 390); stage.setTitle("UIBspSplitPane01"); stage.setScene(scene); stage.show(); } @Override public void handle(Event e) { if(e.getSource() == bn1){ setSplitPane(1); } if(e.getSource() == bn2){ setSplitPane(2); } if(e.getSource() == bn3){ setSplitPane(3); } if(e.getSource() == bn4){ setSplitPane(4); } if(e.getSource() == bn2_2){ setSplitPane(22); } } private void setSplitPane(int nr) { switch (nr) { case 1: splitpane.getItems().clear(); splitpane.getItems().add(new StackPane(editor1)); break; case 2: splitpane.getItems().clear(); splitpane.getItems().add(new StackPane(editor1)); splitpane.getItems().add(new StackPane(editor2)); break; case 3: splitpane.getItems().clear(); splitpane.getItems().add(new StackPane(editor1)); splitpane.getItems().add(new StackPane(editor2)); splitpane.getItems().add(new StackPane(editor3)); break; case 4: splitpane.getItems().clear(); splitpane.getItems().add(new StackPane(editor1)); splitpane.getItems().add(new StackPane(editor2)); splitpane.getItems().add(new StackPane(editor3)); splitpane.getItems().add(new StackPane(editor4)); break; case 22: splitpane.getItems().clear(); VBox vbox = new VBox(); SplitPane splitpane1 = new SplitPane(); SplitPane splitpane2 = new SplitPane(); vbox.getChildren().addAll(splitpane1, splitpane2); splitpane1.getItems().add(new StackPane(editor1)); splitpane1.getItems().add(new StackPane(editor2)); splitpane2.getItems().add(new StackPane(editor3)); splitpane2.getItems().add(new StackPane(editor4)); splitpane.getItems().add(vbox); break; default: errorBox("Fehlerhafter Index in setSplitPane: "+nr,"Hinweis"); break; } // switch } public void errorBox( String message, String title) { Dialog alert = new Alert(Alert.AlertType.ERROR,message); alert.setTitle(title); alert.setHeaderText(title); alert.setResizable(true); alert.show(); // a.setContentText(content); } // ErrorBox public static void main(String[] argv) { launch(argv); } }