Example usage for javafx.scene.control TabPane TabPane

List of usage examples for javafx.scene.control TabPane TabPane

Introduction

In this page you can find the example usage for javafx.scene.control TabPane TabPane.

Prototype

public TabPane() 

Source Link

Document

Constructs a new TabPane.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    final Group group = new Group();
    Scene scene = new Scene(group, 300, 150);
    stage.setScene(scene);/*www  . j a  v  a2 s. c o m*/
    stage.setTitle("Sample");

    TabPane tabPane = new TabPane();
    Tab tab = new Tab();
    tab.setText("new tab");
    tab.setContent(new Rectangle(200, 200, Color.LIGHTSTEELBLUE));
    tabPane.getTabs().add(tab);
    tabPane.getTabs().add(new Tab());

    group.getChildren().add(tabPane);
    stage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Tabs");
    Group root = new Group();
    Scene scene = new Scene(root, 400, 250, Color.WHITE);

    TabPane tabPane = new TabPane();

    BorderPane borderPane = new BorderPane();
    for (int i = 0; i < 5; i++) {
        Tab tab = new Tab();
        tab.setText("Tab" + i);
        HBox hbox = new HBox();
        hbox.getChildren().add(new Label("Tab" + i));
        hbox.setAlignment(Pos.CENTER);/*from  w  w  w.jav  a  2 s. c o  m*/
        tab.setContent(hbox);
        tabPane.getTabs().add(tab);
    }
    // bind to take available space
    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    borderPane.setCenter(tabPane);
    root.getChildren().add(borderPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:Main.java

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Tabs");
    Group root = new Group();
    Scene scene = new Scene(root, 400, 250, Color.WHITE);

    TabPane tabPane = new TabPane();

    BorderPane borderPane = new BorderPane();
    for (int i = 0; i < 5; i++) {
        Tab tab = new Tab();
        tab.setText("Tab" + i);
        HBox hbox = new HBox();
        hbox.getChildren().add(new Label("Tab" + i));
        hbox.setAlignment(Pos.CENTER);/*from w ww.j  a  v a  2  s .c  o  m*/
        tab.setContent(hbox);
        tabPane.getTabs().add(tab);
    }
    tabPane.setSide(Side.LEFT);
    //tabPane.setSide(Side.TOP);
    //tabPane.setSide(Side.RIGHT);
    //tabPane.setSide(Side.BOTTOM);

    // bind to take available space
    borderPane.prefHeightProperty().bind(scene.heightProperty());
    borderPane.prefWidthProperty().bind(scene.widthProperty());

    borderPane.setCenter(tabPane);
    root.getChildren().add(borderPane);
    primaryStage.setScene(scene);
    primaryStage.show();
}

From source file:main.TestManager.java

/**
 * Displays given test. Intended for testing and
 * evaluating correct answers. (student mode only)
 * @param test test to display// w w  w . j a v a  2  s  . c  o  m
 * @param stage 
 */
public static void displayTest(Test test, Stage stage) {
    Debugger.println(test.getName() + " - is displayed.");
    TabPane tabPane = new TabPane();
    int counter = 1;
    for (Question q : test.getQuestions()) {
        Label instruction = new Label(q.question);
        instruction.setStyle("-fx-font-size: 20");
        Pane choices = q.getPaneOfChoices();
        VBox vbox = new VBox(instruction, choices);
        vbox.setSpacing(10);
        Tab tab = new Tab("Otzka " + Integer.toString(counter), vbox);
        tab.setStyle("-fx-font-size: 20");
        tabPane.getTabs().add(tab);
        counter++;
    }

    Button finish = new Button("Ukon?i test!");
    finish.setStyle("-fx-font-size: 20");
    finish.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {
            try {
                test.evaluate(stage);
            } catch (IOException e) {
                Alert alert = new Alert(AlertType.ERROR);
                alert.setContentText("Ojoj, vyskytol sa problm. Aplikcia sa mus ukon?i.");
                alert.showAndWait();
                System.exit(0);
            }
        }
    });
    Button nextQuestion = new Button("alia");
    nextQuestion.setStyle("-fx-font-size: 20");
    nextQuestion.setOnAction(e -> tabPane.getSelectionModel().selectNext());
    HBox buttons = new HBox(finish, nextQuestion);
    buttons.setSpacing(10);
    buttons.setAlignment(Pos.BOTTOM_CENTER);
    VBox outerVBox = new VBox(tabPane, buttons);
    outerVBox.setPadding(new Insets(10, 10, 10, 10));
    Scene scene = new Scene(outerVBox);
    stage.setScene(scene);
    stage.show();
}

From source file:org.jamocha.gui.JamochaGui.java

private Scene generateScene() {
    final TabPane tabPane = new TabPane();
    tabPane.setSide(Side.LEFT);//from  w  w  w.  j  a v a2 s  .c  om

    this.log = new TextArea();
    final Tab logTab = new Tab("Log");
    logTab.setContent(this.log);
    logTab.setClosable(false);

    final Tab networkTab = new Tab("Network");
    networkTab.setClosable(false);
    final ScrollPane scrollPane = new ScrollPane();
    networkTab.setContent(scrollPane);

    this.networkVisualisation = new NetworkVisualisation(this.jamocha.getNetwork());
    this.networkVisualisation.setTranslateX(10);
    this.networkVisualisation.setTranslateY(10);
    this.networkVisualisation.update();
    scrollPane.setContent(this.networkVisualisation);

    tabPane.getTabs().addAll(logTab, networkTab);

    final Scene scene = new Scene(tabPane);
    tabPane.prefHeightProperty().bind(scene.heightProperty());
    tabPane.prefWidthProperty().bind(scene.widthProperty());
    return scene;
}

From source file:com.thomaskuenneth.tkmactuning.TKMacTuning.java

@Override
public void start(Stage primaryStage) {
    TabPane tabPane = new TabPane();
    tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
    // Found here: http://stackoverflow.com/a/17488304/5956451
    tabPane.getStyleClass().add("floating");

    // TODO: propper error handling
    JSONTokener t = new JSONTokener(getClass().getResourceAsStream("resources/plugins.json"));
    JSONArray a = new JSONArray(t);
    a.forEach((Object anObject) -> {
        JSONObject jsonObject = (JSONObject) anObject;
        addPlugin(tabPane, jsonObject.getString("class"), jsonObject.getString("pluginName"));
    });/*from  www .ja v  a  2  s  .com*/

    FlowPane buttonsPane = new FlowPane(Orientation.HORIZONTAL);
    buttonsPane.setPadding(LayoutConstants.PADDING_1);
    buttonsPane.setHgap(LayoutConstants.HORIZONTAL_CONTROL_GAP);
    buttonsPane.setAlignment(Pos.BASELINE_LEFT);
    final Button buttonReread = new Button(getString("reread"));
    buttonReread.setOnAction(event -> {
        PluginManager.reread(this);
    });
    buttonsPane.getChildren().add(buttonReread);
    final Button buttonApply = new Button(getString("apply"));
    buttonApply.setOnAction(event -> {
        PluginManager.save(this);
    });
    buttonsPane.getChildren().add(buttonApply);

    statusbar = new StatusBar();
    BorderPane borderPane = new BorderPane(tabPane);
    borderPane.setTop(buttonsPane);
    borderPane.setBottom(statusbar);
    primaryStage.setScene(new Scene(borderPane, 800, 600));
    primaryStage.setTitle(getString("application_name"));

    ready();
    primaryStage.show();
}

From source file:com.playonlinux.javafx.mainwindow.library.ViewLibrary.java

private void drawContent() {
    libraryTabs = new TabPane();
    libraryTabs.getStyleClass().add("rightPane");

    final Tab installedApplication = new Tab();
    installedApplication.setClosable(false);
    installedApplication.setText(translate("My applications"));
    libraryTabs.getTabs().add(installedApplication);

    applicationListWidget = new ApplicationListWidget(this);
    applicationListWidget.getStyleClass().add("rightPane");

    installedApplication.setContent(applicationListWidget);
}

From source file:be.makercafe.apps.makerbench.Main.java

@Override
public void start(Stage primaryStage) {
    setupWorkspace();// w w  w.j  av  a2 s .  c o  m
    rootContextMenu = createViewerContextMenu();
    viewer = createViewer();

    this.stage = primaryStage;
    BorderPane p = new BorderPane();

    p.setTop(createMenuBar());

    // p.setLeft(viewer);
    tabFolder = new TabPane();
    BorderPane bodyPane = new BorderPane();
    TextArea taConsole = new TextArea();
    taConsole.setPrefSize(Double.MAX_VALUE, 200.0);
    taConsole.setEditable(false);

    Console console = new Console(taConsole);
    PrintStream ps = new PrintStream(console, true);
    System.setOut(ps);
    System.setErr(ps);

    bodyPane.setBottom(taConsole);
    bodyPane.setCenter(tabFolder);
    SplitPane splitpane = new SplitPane();
    splitpane.getItems().addAll(viewer, bodyPane);
    splitpane.setDividerPositions(0.0f, 1.0f);
    p.setCenter(splitpane);

    Scene scene = new Scene(p, 1024, 800);
    //scene.getStylesheets().add(this.getClass().getResource("/styles/java-keywords.css").toExternalForm());

    primaryStage.setResizable(true);
    primaryStage.setTitle("Makerbench");
    primaryStage.setScene(scene);
    //primaryStage.getIcons().add(new Image("/path/to/stackoverflow.jpg"));
    primaryStage.show();
}

From source file:com.scndgen.legends.windows.WindowAbout.java

public WindowAbout() {
    super(StageStyle.UNDECORATED);
    try {//from w ww.  j a  va2 s .  c  o m
        about = IOUtils.toString(
                Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtAbout.txt"),
                Charset.defaultCharset());
        licenseText = IOUtils.toString(
                Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtLicense.txt"),
                Charset.defaultCharset());
        changeLog = IOUtils.toString(
                Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtChangelog.txt"),
                Charset.defaultCharset());
        sourceCode = IOUtils.toString(
                Thread.currentThread().getContextClassLoader().getResourceAsStream("text/txtSourceCode.txt"),
                Charset.defaultCharset());
    } catch (Exception ex) {
        ex.printStackTrace(System.err);
    }
    txtAbout = new TextArea("");
    txtAbout.setText(about);
    txtAbout.setEditable(false);
    txtAbout.setWrapText(true);
    scrlAbout = new ScrollPane(txtAbout);

    txtLicense = new TextArea("");
    txtLicense.setText(licenseText);
    txtLicense.setEditable(false);
    txtLicense.setWrapText(true);
    scrlLicense = new ScrollPane(txtLicense);

    txtChangeLog = new TextArea("");
    txtChangeLog.setText(changeLog);
    txtChangeLog.setEditable(false);
    txtChangeLog.setWrapText(true);
    scrlChangeLog = new ScrollPane(txtChangeLog);

    txtSourceCode = new TextArea("");
    txtSourceCode.setText(sourceCode);
    txtSourceCode.setEditable(false);
    txtSourceCode.setWrapText(true);
    scrlSourceCode = new ScrollPane(txtSourceCode);

    Tab tabAbout = new Tab("About");
    tabAbout.setClosable(false);
    Tab tabLicense = new Tab("License");
    tabLicense.setClosable(false);
    Tab tabDevelop = new Tab("Develop");
    tabDevelop.setClosable(false);
    Tab tabChangelog = new Tab("Changelog");
    tabChangelog.setClosable(false);

    tabAbout.setContent(scrlAbout);
    tabLicense.setContent(scrlLicense);
    tabDevelop.setContent(scrlSourceCode);
    tabChangelog.setContent(scrlChangeLog);

    tabPane = new TabPane();
    tabPane.getTabs().add(tabAbout);
    tabPane.getTabs().add(tabLicense);
    tabPane.getTabs().add(tabChangelog);
    tabPane.getTabs().add(tabDevelop);

    btnOk = new Button("OK");
    btnOk.setOnAction(event -> {
        close();
    });

    VBox vBox = new VBox();
    vBox.setSpacing(4);
    vBox.getChildren().add(tabPane);
    vBox.getChildren().add(btnOk);

    setTitle(Language.get().get(57));
    setScene(new Scene(vBox));
    setResizable(false);
    initModality(Modality.APPLICATION_MODAL);
    show();
}

From source file:ipat_fx.FXMLDocumentController.java

public TabPane getByImage(HashMap<String, ArrayList<GridPane>> map) {

    TabPane tabpane = new TabPane();
    Tab tabForImage;/*www  .java  2  s .  c  o m*/
    FlowPane paneForImage;

    Iterator<String> iterator = map.keySet().iterator();
    while (iterator.hasNext()) {
        tabForImage = new Tab();
        paneForImage = new FlowPane();
        String nameOfArtefact = iterator.next();
        tabForImage.setId("li_" + nameOfArtefact);
        tabForImage.setText(nameOfArtefact);
        ArrayList<GridPane> cells = map.get(nameOfArtefact);
        for (GridPane cell1 : cells) {
            GridPane cell = cell1;
            //paneForImage.add(cell, 0, i);
            paneForImage.getChildren().add(cell);
        }
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(paneForImage);
        tabForImage.setContent(scrollPane);
        tabpane.getTabs().add(tabForImage);
    }
    return tabpane;
}