Example usage for javafx.scene.control Tab setContent

List of usage examples for javafx.scene.control Tab setContent

Introduction

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

Prototype

public final void setContent(Node value) 

Source Link

Document

The content to show within the main TabPane area.

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);/*from   w w  w.ja  v  a2s  .  co  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:org.jamocha.gui.JamochaGui.java

private Scene generateScene() {
    final TabPane tabPane = new TabPane();
    tabPane.setSide(Side.LEFT);/*from  w w w. ja v  a 2 s.  c  o  m*/

    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: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  ava2 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);/* w ww. j a v  a 2  s  . c om*/
        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:de.perdoctus.ebikeconnect.gui.MainWindowController.java

private void initActivitiesTab() throws Exception {
    final Parent parent = fxmlLoader.load(getClass().getResourceAsStream("/fxml/ActivitiesOverview.fxml"));
    this.activitiesOverviewController = fxmlLoader.getController();

    final Tab tab = new Tab(rb.getString("activities"));
    tab.setContent(parent);
    tabPane.getTabs().add(tab);/*w w  w . j a  v a  2s  .c  o m*/

    tab.setOnSelectionChanged(event -> {
        if (tab.isSelected()) {
            activitiesOverviewController.reloadHeaders();
        }
    });

    mnuExport.disableProperty()
            .bind(activitiesOverviewController.currentActivityDetailsGroupProperty().isNull());
}

From source file:de.perdoctus.ebikeconnect.gui.MainWindowController.java

private void initUserTab() {
    final ScrollPane userScrollPane = new ScrollPane(userDetails);

    final Tab tab = new Tab(rb.getString("user-details"));
    tab.setContent(userScrollPane);
    tabPane.getTabs().add(tab);/*  ww  w . jav  a2  s.  c o  m*/

    loginResponse.addListener((observable, oldValue, newValue) -> {
        if (newValue != null) {
            userDetails.setUser(newValue.getUser());
        } else {
            userDetails.setUser(null);
        }
    });
}

From source file:de.pixida.logtest.designer.MainWindow.java

private void addEditorAsNewTab(final Editor editor) {
    final Tab newTab = new Tab();
    newTab.setContent(editor);
    newTab.setGraphic(Icons.getIconGraphics(editor.getIconName()));
    newTab.textProperty().bind(editor.getTitleShort());
    newTab.setOnCloseRequest(event -> {
        if (!this.handleCloseTab()) {
            event.consume(); // Do not continue / leave tab open
        }//from w w w  .  j  a v a2  s  .  c om
    });
    this.tabPane.getTabs().add(newTab);
    this.tabPane.getSelectionModel().select(newTab);
}

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:com.scndgen.legends.windows.WindowAbout.java

public WindowAbout() {
    super(StageStyle.UNDECORATED);
    try {//from   ww w . java2s. 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:com.thomaskuenneth.tkmactuning.TKMacTuning.java

private void addPlugin(TabPane tabPane, String className, String pluginName) {
    try {/*from   w w w. j a  v a  2  s  .  c  om*/
        Class clazz = Class.forName(className);
        Constructor cons = clazz.getConstructor(TKMacTuning.class, String.class);
        AbstractPlugin plugin = (AbstractPlugin) cons.newInstance(this, pluginName);
        String primaryUICategory = plugin.getPrimaryUICategory();
        Tab tab = (Tab) tabPane.getProperties().get(primaryUICategory);
        if (tab == null) {
            tab = new Tab(primaryUICategory);
            tabPane.getProperties().put(primaryUICategory, tab);
            tabPane.getTabs().add(tab);
            VBox content = new VBox();
            content.setPadding(LayoutConstants.PADDING_1);
            content.setSpacing(LayoutConstants.VERTICAL_CONTROL_GAP);
            tab.setContent(content);
        }
        VBox content = (VBox) tab.getContent();
        Node node = plugin.getNode();
        if (node != null) {
            String secondaryUICategory = plugin.getSecondaryUICategory();
            if (AbstractPlugin.ROOT.equals(secondaryUICategory)) {
                content.getChildren().add(node);
            } else {
                Pane group = (Pane) tabPane.getProperties().get(GROUP + secondaryUICategory);
                if (group == null) {
                    group = new VBox(LayoutConstants.VERTICAL_CONTROL_GAP);
                    tabPane.getProperties().put(GROUP + secondaryUICategory, group);
                    HBox headline = new HBox();
                    headline.setStyle(
                            "-fx-border-insets: 0 0 1 0; -fx-border-color: transparent transparent -fx-text-box-border transparent; -fx-border-width: 1;");
                    headline.getChildren().add(new Label(secondaryUICategory));
                    group.getChildren().add(headline);
                    content.getChildren().add(group);
                }
                group.getChildren().add(node);
            }
        } else {
            LOGGER.log(Level.SEVERE, "could not create control for plugin {0}({1})",
                    new Object[] { className, pluginName });
        }
    } catch (InstantiationException | ClassNotFoundException | NoSuchMethodException | SecurityException
            | InvocationTargetException | IllegalAccessException ex) {
        LOGGER.log(Level.SEVERE, "addPlugin()", ex);
    }
}