Example usage for javafx.scene.control Tab Tab

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

Introduction

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

Prototype

public Tab() 

Source Link

Document

Creates a tab with no title.

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);//ww  w  . j a  v  a  2 s.  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: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.  ja  va2s .com*/
        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  w  w. ja v  a  2s  .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: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:de.micromata.mgc.javafx.launcher.gui.AbstractConfigDialog.java

private Tab createTab(LocalSettingsConfigModel configModel,
        Pair<Pane, ? extends AbstractConfigTabController<?>> wc) {
    AbstractConfigTabController<?> contrl = wc.getSecond();
    contrl.setConfigDialog(this);

    Pane tabPane = wc.getFirst();/*  w w  w  . j a v  a  2s  .c o  m*/

    contrl.setTabPane(tabPane);
    Tab tabB = new Tab();

    AnchorPane tabContentPane = new AnchorPane();
    tabContentPane.setMaxHeight(Integer.MAX_VALUE);
    //    tabContentPane.setPrefHeight(500);
    FeedbackPanel feedback = new FeedbackPanel();

    feedback.setPrefHeight(100);
    feedback.setMinHeight(100);
    FXEvents.get().addEventHandler(this, feedback, FeedbackPanelEvents.CLEAR, event -> {
        feedback.clearMessages();
    });
    contrl.setFeedback(feedback);
    tabContentPane.getChildren().add(tabPane);
    tabContentPane.getChildren().add(feedback);
    AnchorPane.setTopAnchor(tabPane, 2.0);
    AnchorPane.setRightAnchor(tabPane, 0.0);
    AnchorPane.setLeftAnchor(tabPane, 0.0);
    AnchorPane.setBottomAnchor(tabPane, 70.0);
    AnchorPane.setBottomAnchor(feedback, 0.0);

    tabB.setContent(tabContentPane);
    AnchorPane.setTopAnchor(tabContentPane, 0.0);
    AnchorPane.setRightAnchor(tabContentPane, 0.0);
    AnchorPane.setLeftAnchor(tabContentPane, 0.0);
    AnchorPane.setBottomAnchor(tabContentPane, 0.0);

    Node scrollPane = tabPane.getChildren().get(0);
    AnchorPane.setTopAnchor(scrollPane, 0.0);
    AnchorPane.setRightAnchor(scrollPane, 0.0);
    AnchorPane.setLeftAnchor(scrollPane, 0.0);
    AnchorPane.setBottomAnchor(scrollPane, 0.0);

    configurationTabs.getTabs().add(tabB);
    tabController.add(contrl);
    contrl.setTab(tabB);
    ((ModelController) contrl).setModel(configModel);
    contrl.initializeWithModel();
    contrl.addToolTips();
    tabB.setText(contrl.getTabTitle());
    contrl.registerValMessageReceivers();

    return tabB;
}

From source file:gov.va.isaac.gui.preferences.PreferencesViewController.java

public void aboutToShow() {
    // Using allValid_ to prevent rerunning content of aboutToShow()
    if (allValid_ == null) {
        // These listeners are for debug and testing only. They may be removed at any time.
        UserProfileBindings userProfileBindings = AppContext.getService(UserProfileBindings.class);
        for (Property<?> property : userProfileBindings.getAll()) {
            property.addListener(new ChangeListener<Object>() {
                @Override/*from   w  w  w  . j a  va2  s .c o m*/
                public void changed(ObservableValue<? extends Object> observable, Object oldValue,
                        Object newValue) {
                    logger.debug("{} property changed from {} to {}", property.getName(), oldValue, newValue);
                }
            });
        }

        // load fields before initializing allValid_
        // in case plugin.validationFailureMessageProperty() initialized by getNode()
        tabPane_.getTabs().clear();
        List<PreferencesPluginViewI> sortableList = new ArrayList<>();
        Comparator<PreferencesPluginViewI> comparator = new Comparator<PreferencesPluginViewI>() {
            @Override
            public int compare(PreferencesPluginViewI o1, PreferencesPluginViewI o2) {
                if (o1.getTabOrder() == o2.getTabOrder()) {
                    return o1.getName().compareTo(o2.getName());
                } else {
                    return o1.getTabOrder() - o2.getTabOrder();
                }
            }
        };
        for (PreferencesPluginViewI plugin : plugins_) {
            sortableList.add(plugin);
        }
        Collections.sort(sortableList, comparator);
        for (PreferencesPluginViewI plugin : sortableList) {
            logger.debug("Adding PreferencesPluginView tab \"{}\"", plugin.getName());
            Label tabLabel = new Label(plugin.getName());

            tabLabel.setMaxHeight(Double.MAX_VALUE);
            tabLabel.setMaxWidth(Double.MAX_VALUE);
            Tab pluginTab = new Tab();
            pluginTab.setGraphic(tabLabel);
            Region content = plugin.getContent();
            content.setMaxWidth(Double.MAX_VALUE);
            content.setMaxHeight(Double.MAX_VALUE);
            content.setPadding(new Insets(5.0));

            Label errorMessageLabel = new Label();
            errorMessageLabel.textProperty().bind(plugin.validationFailureMessageProperty());
            errorMessageLabel.setAlignment(Pos.BOTTOM_CENTER);
            TextErrorColorHelper.setTextErrorColor(errorMessageLabel);

            VBox vBox = new VBox();
            vBox.getChildren().addAll(errorMessageLabel, content);
            vBox.setMaxWidth(Double.MAX_VALUE);
            vBox.setAlignment(Pos.TOP_CENTER);

            plugin.validationFailureMessageProperty().addListener(new ChangeListener<String>() {
                @Override
                public void changed(ObservableValue<? extends String> observable, String oldValue,
                        String newValue) {
                    if (newValue != null && !StringUtils.isEmpty(newValue)) {
                        TextErrorColorHelper.setTextErrorColor(tabLabel);
                    } else {
                        TextErrorColorHelper.clearTextErrorColor(tabLabel);
                    }
                }
            });
            //Initialize, if stored value is wrong
            if (StringUtils.isNotEmpty(plugin.validationFailureMessageProperty().getValue())) {
                TextErrorColorHelper.setTextErrorColor(tabLabel);
            }
            pluginTab.setContent(vBox);
            tabPane_.getTabs().add(pluginTab);
        }

        allValid_ = new ValidBooleanBinding() {
            {
                ArrayList<ReadOnlyStringProperty> pluginValidationFailureMessages = new ArrayList<>();
                for (PreferencesPluginViewI plugin : plugins_) {
                    pluginValidationFailureMessages.add(plugin.validationFailureMessageProperty());
                }
                bind(pluginValidationFailureMessages
                        .toArray(new ReadOnlyStringProperty[pluginValidationFailureMessages.size()]));
                setComputeOnInvalidate(true);
            }

            @Override
            protected boolean computeValue() {
                for (PreferencesPluginViewI plugin : plugins_) {
                    if (plugin.validationFailureMessageProperty().get() != null
                            && plugin.validationFailureMessageProperty().get().length() > 0) {
                        this.setInvalidReason(plugin.validationFailureMessageProperty().get());

                        logger.debug("Setting PreferencesView allValid_ to false because \"{}\"",
                                this.getReasonWhyInvalid().get());
                        return false;
                    }
                }

                logger.debug("Setting PreferencesView allValid_ to true");

                this.clearInvalidReason();
                return true;
            }
        };

        okButton_.disableProperty().bind(allValid_.not());
        // set focus on default
        // Platform.runLater(...);
    }

    // Reload persisted values every time view opened
    for (PreferencesPluginViewI plugin : plugins_) {
        plugin.getContent();
    }
}

From source file:Pages.LandingPage.java

public void createTabs(Stage theStage) {

    //Create Tab with log in box
    createLogin();/*from  ww w.j a  va  2s  .  c o  m*/
    tabPane = new JFXTabPane();
    tabPane.setStyle("-fx-background-color:WHITE;");
    title = new Label("Sign in");
    title.setTextFill(Color.WHITE);
    title.setStyle("-fx-font-size:15px;");
    tab = new Tab();
    tab.setStyle("-fx-background-color:TRANSPARENT; -fx-alignment:center; -fx-font-weight: bold");
    tab.setContent(logbox);
    tab.setText("");
    tab.setGraphic(title);

    tabPane.getTabs().add(tab);

    // Create Tab with sign up box
    createUser(theStage);
    title = new Label("Sign up");
    title.setTextFill(Color.WHITE);
    title.setStyle("-fx-font-size:15px;");
    tab = new Tab();
    tab.setStyle("-fx-background-color:TRANSPARENT; -fx-alignment:center; -fx-font-weight: bold");
    tab.setContent(scrollpane);
    tab.setText("");
    tab.setGraphic(title);

    tabPane.getTabs().add(tab);
    tabPane.relocate(0, 200);

    tabPane.getSelectionModel().selectedItemProperty().addListener((obs, ov, nv) -> {
        if (tabPane.getSelectionModel().isSelected(0) == true) {
            icon.setVisible(true);
            save_icon.setVisible(false);
        } else {
            save_icon.setVisible(true);
            icon.setVisible(false);
        }
    });
}

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

private void addEditorAsNewTab(final Editor editor) {
    final Tab newTab = new Tab();
    newTab.setContent(editor);// w w  w .  j  a  v  a2  s .co m
    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
        }
    });
    this.tabPane.getTabs().add(newTab);
    this.tabPane.getSelectionModel().select(newTab);
}

From source file:ipat_fx.FXMLDocumentController.java

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

    TabPane tabpane = new TabPane();
    Tab tabForImage;/*from  w  w  w. ja v a  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;
}

From source file:ipat_fx.FXMLDocumentController.java

public TabPane getByProfile(HashMap<String, ArrayList<GridPane>> map, int noOfProfiles) {

    TabPane tabpane = new TabPane();
    Tab tabForProfile;/*  w  w  w  .  j a va  2  s.c o m*/
    FlowPane paneForProfile;

    for (int i = 0; i < noOfProfiles; i++) {
        tabForProfile = new Tab();
        paneForProfile = new FlowPane();
        tabForProfile.setId("li_Profile_" + i);
        tabForProfile.setText("Profile " + i);
        int j = 0;
        for (Iterator<String> iterator = map.keySet().iterator(); iterator.hasNext(); j++) {
            String nameOfArtefact = iterator.next();
            ArrayList<GridPane> cells = map.get(nameOfArtefact);
            paneForProfile.getChildren().add(cells.get(i));
        }
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setContent(paneForProfile);
        tabForProfile.setContent(scrollPane);
        tabpane.getTabs().add(tabForProfile);
    }
    return tabpane;
}