Example usage for javafx.scene.control TabPane getTabs

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

Introduction

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

Prototype

public final ObservableList<Tab> getTabs() 

Source Link

Document

The tabs to display in this TabPane.

Usage

From source file:Main.java

private static Node lookupInternal(Node node, String id) {
    if (id.equals(node.getId())) {
        return node;
    }/*from   ww w .  jav  a  2 s .co m*/
    if (node instanceof Parent) {
        for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
            Node result = lookupInternal(child, id);
            if (result != null) {
                return result;
            }
        }
        if (node instanceof SplitPane) {
            SplitPane sp = (SplitPane) node;
            Node result = null;
            for (Node child : sp.getItems()) {
                result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof ScrollPane) {
            ScrollPane sp = (ScrollPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof BorderPane) {
            BorderPane sp = (BorderPane) node;
            Node result = null;
            if (sp.getBottom() != null) {
                result = lookupInternal(sp.getBottom(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getTop() != null) {
                result = lookupInternal(sp.getTop(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getLeft() != null) {
                result = lookupInternal(sp.getLeft(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getRight() != null) {
                result = lookupInternal(sp.getRight(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getCenter() != null) {
                result = lookupInternal(sp.getCenter(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TitledPane) {
            TitledPane sp = (TitledPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof Accordion) {
            Accordion sp = (Accordion) node;
            for (Node child : ((Accordion) node).getPanes()) {
                Node result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TabPane) {
            TabPane bp = (TabPane) node;
            Node result = null;
            for (Tab tab : bp.getTabs()) {
                result = lookupInternal(tab.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
    }
    return null;
}

From source file:Main.java

private static Node lookupInternal(Node node, String id) {
    if (id.equals(node.getId())) {
        return node;
    }/*from   w  w  w . ja va 2s  . c  o m*/
    if (node instanceof Parent) {
        for (Node child : ((Parent) node).getChildrenUnmodifiable()) {
            Node result = lookupInternal(child, id);
            if (result != null) {
                return result;
            }
        }
        if (node instanceof SplitPane) {
            SplitPane sp = (SplitPane) node;
            Node result = null;
            for (Node child : sp.getItems()) {
                result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof ScrollPane) {
            ScrollPane sp = (ScrollPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof BorderPane) {
            BorderPane sp = (BorderPane) node;
            Node result = null;
            if (sp.getBottom() != null) {
                result = lookupInternal(sp.getBottom(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getTop() != null) {
                result = lookupInternal(sp.getTop(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getLeft() != null) {
                result = lookupInternal(sp.getLeft(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getRight() != null) {
                result = lookupInternal(sp.getRight(), id);
                if (result != null) {
                    return result;
                }
            }
            if (sp.getCenter() != null) {
                result = lookupInternal(sp.getCenter(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TitledPane) {
            TitledPane sp = (TitledPane) node;
            Node result = null;
            if (sp.getContent() != null) {
                result = lookupInternal(sp.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof Accordion) {
            for (Node child : ((Accordion) node).getPanes()) {
                Node result = lookupInternal(child, id);
                if (result != null) {
                    return result;
                }
            }
        }
        if (node instanceof TabPane) {
            TabPane bp = (TabPane) node;
            Node result = null;
            for (Tab tab : bp.getTabs()) {
                result = lookupInternal(tab.getContent(), id);
                if (result != null) {
                    return result;
                }
            }
        }
    }
    return null;
}

From source file:main.TestManager.java

/**
 * Displays given test. Intended for testing and
 * evaluating correct answers. (student mode only)
 * @param test test to display//ww  w  . j ava 2s  . 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: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 .  j a v  a 2  s.com
    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:pe.edu.system.jcmr.util.UtilidadesFx.java

/**
 * /*from www.  j  a  va  2  s  .c  om*/
 * @param pane
 * @param tabPane
 */
public void OpenPane(Tab pane, TabPane tabPane) {
    if (!tabPane.getTabs().contains(pane)) {
        tabPane.getTabs().add(pane);
    }
}

From source file:pe.edu.system.jcmr.util.UtilidadesFx.java

/**
 * /*w w w  .  j  a va 2 s  .co  m*/
 * @param pane
 * @param tabPane
 */
public void ClosePane(Tab pane, TabPane tabPane) {

    if (tabPane.getTabs().contains(pane)) {
        tabPane.getTabs().remove(pane);
    }
}

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);// www .  j  a  v  a 2s  .  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 w w .  ja v  a  2s.co  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:ipat_fx.FXMLDocumentController.java

@FXML
public void resetScores() {

    HashMap<String, Hint> hintMap = controller.hints;
    TabPane tabpane = (TabPane) byProfilePane.getChildren().get(0);
    Tab tab = null;//ww  w  .j av a 2s  . c  o  m
    if (tabFlag.equalsIgnoreCase("byProfile")) {
        tab = tabpane.getTabs().get(0);
    } else if (tabFlag.equalsIgnoreCase("byImage")) {
        tab = tabpane.getTabs().get(0);
    } else {
        Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null,
                "Something wrong with tabFlag");
    }
    ScrollPane scrollPane = (ScrollPane) tab.getContent();
    FlowPane flowPane = (FlowPane) scrollPane.getContent();
    Iterator<Node> cellsIterator = flowPane.getChildren().iterator();
    while (cellsIterator.hasNext()) {
        GridPane cell = (GridPane) cellsIterator.next();
        Iterator<Node> cellIterator = cell.getChildren().iterator();
        while (cellIterator.hasNext()) {
            Node cellElement = cellIterator.next();
            if (cellElement instanceof Slider) {
                Set<String> keySet = hintMap.keySet();// get the hints one by one and apply to cell
                int keyCount = 0;
                for (String key : keySet) {
                    Hint h = hintMap.get(key);
                    Slider slider = ((Slider) cellElement);
                    String[] split = slider.getId().split("_");
                    if (split[0].equalsIgnoreCase(h.getHintName())) {
                        slider.setValue(Double.valueOf(h.getDefaultValue()));
                    }
                }
            }
            if (cellElement instanceof CheckBox) {
                ((CheckBox) cellElement).setSelected(false);
            }
        }
    }
}

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

private void addPlugin(TabPane tabPane, String className, String pluginName) {
    try {/*from  w ww  .  j  a  v  a  2  s .co m*/
        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);
    }
}