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(String text) 

Source Link

Document

Creates a tab with a text title.

Usage

From source file:org.beryx.viewreka.fxapp.Viewreka.java

public void refreshViews() {
    if (project == null)
        return;//from   w w w  .j  a  v  a  2 s.  c om

    project.getProjectSettingsManager().saveSettings();

    viewsTabPane.getTabs().clear();

    ProjectSettings projectSettings = project.getProjectSettingsManager().getSettings();
    String currentViewName = projectSettings.getCurrentView();

    Tab selectedTab = null;
    for (FxView view : project.getViews()) {
        String viewName = view.getName();
        final Tab tab = new Tab(viewName);
        viewsTabPane.getTabs().add(tab);
        if (viewName.equals(currentViewName)) {
            selectedTab = tab;
        }

        final ViewPane<?> viewPane = ViewPane.fromModel(view, projectSettings);
        tab.setContent(viewPane);

        viewPane.autosize();

        tab.setOnSelectionChanged(new EventHandler<Event>() {
            @Override
            public void handle(Event event) {
                viewPane.autosize();
                Tab selTab = viewsTabPane.getSelectionModel().getSelectedItem();
                if (selTab != null) {
                    String selectedView = selTab.getText();
                    projectSettings.setCurrentView(selectedView);
                }
            }
        });
    }

    if (selectedTab != null) {
        viewsTabPane.getSelectionModel().select(selectedTab);
    }
    layout();
}