List of usage examples for javafx.scene.control Tab Tab
public Tab(String text, Node content)
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 w w .java 2 s .co 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:com.waoss.leaf.LeafController.java
@FXML public void fileOpenOnAction(ActionEvent actionEvent) throws Exception { File file = fileChooser.showOpenDialog(Leaf.getInstance().getStage()); final SyntaxRegion syntaxRegion = new SyntaxRegion(LeafUtils.getSyntaxArea(file.getName())); syntaxRegion.setFile(file);/*w w w.j a v a 2 s . c om*/ final Tab tab = new Tab(file.getName(), syntaxRegion); tabPane.getTabs().add(tab); syntaxRegion.getSyntaxArea().clear(); syntaxRegion.getSyntaxArea().setPrefSize(width, height); syntaxRegion.getSyntaxArea().replaceText(0, 0, IOUtils.toString(new FileReader(file))); tabPane.getSelectionModel().select(tab); }
From source file:tachyon.view.ProjectProperties.java
public ProjectProperties(JavaProject project, Window w) { this.project = project; stage = new Stage(); stage.initOwner(w);/* w w w. j a va 2 s . c o m*/ stage.initModality(Modality.APPLICATION_MODAL); stage.setWidth(600); stage.setTitle("Project Properties - " + project.getProjectName()); stage.getIcons().add(tachyon.Tachyon.icon); stage.setResizable(false); HBox mai, libs, one, two, thr, fou; ListView<String> compileList, runtimeList; Button compileAdd, compileRemove, preview, selectIm, runtimeAdd, runtimeRemove; TextField iconField; stage.setScene(new Scene(new VBox(5, pane = new TabPane( new Tab("Library Settings", box1 = new VBox(15, libs = new HBox(10, new Label("External Libraries"), libsView = new ListView<>(), new VBox(5, addJar = new Button("Add Jar"), removeJar = new Button("Remove Jar"))))), new Tab("Program Settings", new ScrollPane(box2 = new VBox(15, one = new HBox(10, new Label("Main-Class"), mainClass = new TextField(project.getMainClassName()), select = new Button("Select")), two = new HBox(10, new Label("Compile-Time Arguments"), compileList = new ListView<>(), new VBox(5, compileAdd = new Button("Add Argument"), compileRemove = new Button("Remove Argument")))))), new Tab("Deployment Settings", box3 = new VBox(15, thr = new HBox(10, new Label("Icon File"), iconField = new TextField(project.getFileIconPath()), preview = new Button("Preview Image"), selectIm = new Button("Select Icon")), fou = new HBox(10, new Label("Runtime Arguments"), runtimeList = new ListView<>(), new VBox(5, runtimeAdd = new Button("Add Argument"), runtimeRemove = new Button("Remove Argument")))))), new VBox(15, mai = new HBox(10, cancel = new Button("Cancel"), confirm = new Button("Confirm")))))); if (applyCss.get()) { stage.getScene().getStylesheets().add(css); } for (Tab b : pane.getTabs()) { b.setClosable(false); } mainClass.setPromptText("Main-Class"); box1.setPadding(new Insets(5, 10, 5, 10)); mai.setAlignment(Pos.CENTER_RIGHT); mai.setPadding(box1.getPadding()); libs.setAlignment(Pos.CENTER); one.setAlignment(Pos.CENTER); two.setAlignment(Pos.CENTER); thr.setAlignment(Pos.CENTER); fou.setAlignment(Pos.CENTER); box1.setAlignment(Pos.CENTER); box2.setPadding(box1.getPadding()); box2.setAlignment(Pos.CENTER); box3.setPadding(box1.getPadding()); box3.setAlignment(Pos.CENTER); mainClass.setEditable(false); mainClass.setPrefWidth(200); for (JavaLibrary lib : project.getAllLibs()) { libsView.getItems().add(lib.getBinaryAbsolutePath()); } for (String sa : project.getCompileTimeArguments().keySet()) { compileList.getItems().add(sa + ":" + project.getCompileTimeArguments().get(sa)); } for (String sa : project.getRuntimeArguments()) { runtimeList.getItems().add(sa); } compileAdd.setOnAction((e) -> { Dialog<Pair<String, String>> dialog = new Dialog<>(); dialog.setTitle("Compiler Argument"); dialog.initOwner(stage); dialog.setHeaderText("Entry the argument"); ButtonType loginButtonType = new ButtonType("Done", ButtonData.OK_DONE); dialog.getDialogPane().getButtonTypes().addAll(loginButtonType, ButtonType.CANCEL); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(20, 150, 10, 10)); TextField username = new TextField(); username.setPromptText("Key"); TextField password = new TextField(); password.setPromptText("Value"); grid.add(new Label("Key:"), 0, 0); grid.add(username, 1, 0); grid.add(new Label("Value:"), 0, 1); grid.add(password, 1, 1); Node loginButton = dialog.getDialogPane().lookupButton(loginButtonType); loginButton.setDisable(true); username.textProperty().addListener((observable, oldValue, newValue) -> { loginButton.setDisable(newValue.trim().isEmpty()); }); dialog.getDialogPane().setContent(grid); Platform.runLater(() -> username.requestFocus()); dialog.setResultConverter(dialogButton -> { if (dialogButton == loginButtonType) { return new Pair<>(username.getText(), password.getText()); } return null; }); Optional<Pair<String, String>> result = dialog.showAndWait(); if (result.isPresent()) { compileList.getItems().add(result.get().getKey() + ":" + result.get().getValue()); } }); compileRemove.setOnAction((e) -> { if (compileList.getSelectionModel().getSelectedItem() != null) { compileList.getItems().remove(compileList.getSelectionModel().getSelectedItem()); } }); runtimeAdd.setOnAction((e) -> { TextInputDialog dia = new TextInputDialog(); dia.setTitle("Add Runtime Argument"); dia.setHeaderText("Enter an argument"); dia.initOwner(stage); Optional<String> res = dia.showAndWait(); if (res.isPresent()) { runtimeList.getItems().add(res.get()); } }); runtimeRemove.setOnAction((e) -> { if (runtimeList.getSelectionModel().getSelectedItem() != null) { runtimeList.getItems().remove(runtimeList.getSelectionModel().getSelectedItem()); } }); preview.setOnAction((e) -> { if (!iconField.getText().isEmpty()) { if (iconField.getText().endsWith(".ico")) { List<BufferedImage> read = new ArrayList<>(); try { read.addAll(ICODecoder.read(new File(iconField.getText()))); } catch (IOException ex) { } if (read.size() >= 1) { Image im = SwingFXUtils.toFXImage(read.get(0), null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } else if (iconField.getText().endsWith(".icns")) { try { BufferedImage ima = Imaging.getBufferedImage(new File(iconField.getText())); if (ima != null) { Image im = SwingFXUtils.toFXImage(ima, null); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } catch (ImageReadException | IOException ex) { } } else { Image im = new Image(new File(iconField.getText()).toURI().toString()); Stage st = new Stage(); st.initOwner(stage); st.initModality(Modality.APPLICATION_MODAL); st.setTitle("Icon Preview"); st.getIcons().add(Tachyon.icon); st.setScene(new Scene(new BorderPane(new ImageView(im)))); if (applyCss.get()) { st.getScene().getStylesheets().add(css); } st.showAndWait(); } } }); selectIm.setOnAction((e) -> { FileChooser fc = new FileChooser(); fc.setTitle("Icon File"); String OS = System.getProperty("os.name").toLowerCase(); fc.getExtensionFilters().add(new ExtensionFilter("Icon File", OS.contains("win") ? getWindowsImageExtensions() : getMacImageExtensions())); fc.setSelectedExtensionFilter(fc.getExtensionFilters().get(0)); File lf = fc.showOpenDialog(stage); if (lf != null) { iconField.setText(lf.getAbsolutePath()); } }); addJar.setOnAction((e) -> { FileChooser f = new FileChooser(); f.setTitle("External Libraries"); f.setSelectedExtensionFilter(new ExtensionFilter("Jar Files", "*.jar")); List<File> showOpenMultipleDialog = f.showOpenMultipleDialog(stage); if (showOpenMultipleDialog != null) { for (File fi : showOpenMultipleDialog) { if (!libsView.getItems().contains(fi.getAbsolutePath())) { libsView.getItems().add(fi.getAbsolutePath()); } } } }); removeJar.setOnAction((e) -> { String selected = libsView.getSelectionModel().getSelectedItem(); if (selected != null) { libsView.getItems().remove(selected); } }); select.setOnAction((e) -> { List<String> all = getAll(); ChoiceDialog<String> di = new ChoiceDialog<>(project.getMainClassName(), all); di.setTitle("Select Main Class"); di.initOwner(stage); di.setHeaderText("Select A Main Class"); Optional<String> show = di.showAndWait(); if (show.isPresent()) { mainClass.setText(show.get()); } }); cancel.setOnAction((e) -> { stage.close(); }); confirm.setOnAction((e) -> { project.setMainClassName(mainClass.getText()); project.setFileIconPath(iconField.getText()); project.setRuntimeArguments(runtimeList.getItems()); HashMap<String, String> al = new HashMap<>(); for (String s : compileList.getItems()) { String[] spl = s.split(":"); al.put(spl[0], spl[1]); } project.setCompileTimeArguments(al); project.setAllLibs(libsView.getItems()); stage.close(); }); }
From source file:cz.lbenda.dataman.rc.DatamanApp.java
/** Add node to center pane */ public Tab addToCenter(String title, Node node, boolean closable) { Tab tab = new Tab(title, node); tab.setClosable(closable);//from w w w .ja v a2 s . c o m this.centerTabs.getTabs().add(tab); this.centerTabs.getSelectionModel().select(tab); return tab; }
From source file:cz.lbenda.dataman.rc.DatamanApp.java
/** Add node to center pane */ private void addRemoveToDetail(@Nonnull String title, @Nonnull Node node, boolean closable) { boolean removed = false; for (Iterator<Tab> itt = detailTabs.getTabs().iterator(); itt.hasNext();) { Tab tab = itt.next();/*from ww w . ja v a2 s.c o m*/ if (node.equals(tab.getContent())) { itt.remove(); removed = true; } } if (!removed) { Tab tab = new Tab(title, node); tab.setClosable(closable); this.detailTabs.getTabs().add(tab); this.detailTabs.getSelectionModel().select(tab); } }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane createSidePane() { BorderPane pane = new BorderPane(); TabPane tabPane = new TabPane(); kmDisplay = new KaplanMeierDisplay(null, null, null, null); BorderPane paneKaplanMeier = new BorderPane(); paneKaplanMeier.setCenter(kmDisplay.getView()); paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10)); // comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty()); comboMainMeasurement.setMaxWidth(Double.MAX_VALUE); comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc.")); GridPane kmTop = new GridPane(); kmTop.add(new Label("Score"), 0, 0); kmTop.add(comboMainMeasurement, 1, 0); kmTop.add(new Label("Survival type"), 0, 1); kmTop.add(comboSurvival, 1, 1);//w ww . j a v a 2 s . c om comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)")); comboSurvival.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS); GridPane.setHgrow(comboSurvival, Priority.ALWAYS); kmTop.setHgap(5); paneKaplanMeier.setTop(kmTop); // kmDisplay.setOrientation(Orientation.VERTICAL); histogramDisplay = new HistogramDisplay(model, false); comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshCombo(); histogramDisplay.showHistogram(n); updateSurvivalCurves(); }); comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshHistogram(); scatterPane.updateChart(); updateSurvivalCurves(); }); comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { updateSurvivalCurves(); }); // Create a Tab for showing images BorderPane paneImages = new BorderPane(); CheckBox cbShowOverlay = new CheckBox("Show overlay"); imageAvailability.addListener((c, v, n) -> { if (n == ImageAvailability.OVERLAY_ONLY) cbShowOverlay.setSelected(true); else if (n == ImageAvailability.IMAGE_ONLY) cbShowOverlay.setSelected(false); cbShowOverlay.setDisable(n != ImageAvailability.BOTH); }); ListView<TMAEntry> listImages = new ListView<>(); listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache)); listImages.widthProperty().addListener((v, o, n) -> listImages.refresh()); listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;"); table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> { List<TMAEntry> entries = new ArrayList<>(); for (TreeItem<TMAEntry> item : e.getList()) { if (item.getChildren().isEmpty()) { if (item.getValue().hasImage() || item.getValue().hasOverlay()) entries.add(item.getValue()); } else { for (TreeItem<TMAEntry> item2 : item.getChildren()) { if (item2.getValue().hasImage() || item2.getValue().hasOverlay()) entries.add(item2.getValue()); } } listImages.getItems().setAll(entries); } }); cbShowOverlay.setAlignment(Pos.CENTER); cbShowOverlay.setMaxWidth(Double.MAX_VALUE); cbShowOverlay.setPadding(new Insets(5, 5, 5, 5)); cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh()); paneImages.setCenter(listImages); paneImages.setTop(cbShowOverlay); // Determine visibility based upon whether there are any images to show // Tab tabImages = new Tab("Images", paneImages); ScrollPane scrollPane = new ScrollPane(paneKaplanMeier); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); Tab tabSurvival = new Tab("Survival", scrollPane); tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()), // tabImages, new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()), tabSurvival); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); // if (imageAvailability.get() != ImageAvailability.NONE) // tabPane.getTabs().add(1, tabImages); // // imageAvailability.addListener((c, v, n) -> { // if (n == ImageAvailability.NONE) // tabPane.getTabs().remove(tabImages); // else if (!tabPane.getTabs().contains(tabImages)) // tabPane.getTabs().add(1, tabImages); // }); // tabSurvival.visibleProperty().bind( // Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns) // ); pane.setCenter(tabPane); pane.setMinWidth(350); return pane; }