Example usage for javafx.scene.control TabPane getSelectionModel

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

Introduction

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

Prototype

public final SingleSelectionModel<Tab> getSelectionModel() 

Source Link

Document

Gets the model used for tab selection.

Usage

From source file:com.jscriptive.moneyfx.ui.account.AccountFrame.java

public void importTransactionsFired(ActionEvent actionEvent) {
    TransactionImportDialog dialog = new TransactionImportDialog(bankRepository.findAll());
    Optional<Pair<String, File>> result = dialog.showAndWait();
    if (result.isPresent()) {
        String bank = result.get().getKey();
        File file = result.get().getValue();
        TransactionExtractor extractor = TransactionExtractorProvider.getInstance()
                .getTransactionExtractor(bank);
        Account account = extractAccountData(file.toURI(), extractor);
        if (account != null) {
            extractTransactionData(file.toURI(), extractor, account);
            Platform.runLater(() -> dataSummaryLabel
                    .setText("Accounts: " + accountData.size() + ", balance: " + getAbsSum(accountData)));
        }/*  w ww .j  av  a 2  s . c o  m*/
        TabPane tabPane = (TabPane) dataTable.getScene().lookup("#tabPane");
        tabPane.getSelectionModel().select(1);
    }
}

From source file:main.TestManager.java

/**
 * Displays given test. Intended for testing and
 * evaluating correct answers. (student mode only)
 * @param test test to display/*from   w ww.ja  va  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();
}