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.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.event.Event; public class UIBspTabPane01 extends Application implements EventHandler{ private Stage stage = null; private String filename=""; private Button bnNew = new Button("New"); private TabPane tabpane = null; @Override public void start(Stage stage) { this.stage = stage; BorderPane root = new BorderPane(); root.setTop( setTopElements() ); root.setCenter( setCenterElements() ); Scene scene= new Scene(root, 660, 490); scene.getStylesheets().add("UIBspTabPane01.css"); stage.setTitle("UIBTabPane01"); stage.setScene(scene); stage.show(); } private Pane setTopElements() { VBox vbox = new VBox(22); vbox.setAlignment(Pos.CENTER); vbox.setFillWidth(true); bnNew.setFont(new Font(22)); bnNew.setOnAction(this); ToolBar toolBar = new ToolBar( bnNew ); vbox.getChildren().add(toolBar); return vbox ; } private TabPane setCenterElements() { tabpane = new TabPane(); tabpane.setTabMinHeight(22); tabpane.setTabMaxHeight(44); return tabpane; } @Override public void handle(Event e) { if(e.getSource() == bnNew){ newFile(); } } private void newFile() { insertTab(); } private void insertTab() { TextArea editor = new TextArea(); editor.setFont(new Font(22)); Tab tab = new Tab("Neu"); tab.setContent(editor); tabpane.getTabs().add(tab); } public static void main(String[] argv) { launch(argv); } }