private void updateTabTitle() { final HBox title = new HBox(); title.setAlignment(Pos.CENTER); if (isAutoRefresh()) { final ProgressIndicator progressIndicator = new ProgressIndicator(); progressIndicator.setMaxSize(15, 15); title.getChildren().add(progressIndicator); title.getChildren().add(new Label(" ")); } // If the search value is too long, show only a substring final String searchValue = searchField.getText().length() > MAX_SEARCH_VALUE_CHARACTERS ? searchField.getText().substring(0, MAX_SEARCH_VALUE_CHARACTERS) + "..." : searchField.getText(); title .getChildren() .add( new Label( "Search: \"" + searchValue + "\"" + " [" + foundMessages.size() + " found / " + seachedCount + " searched]")); tab.setText(null); tab.setGraphic(title); }
@Override public void initUI() { AnchorPane anchorPane = new AnchorPane(); anchorPane.setPrefHeight(90.0); anchorPane.setPrefWidth(384.0); Label label = new Label(getApplication().getMessageSource().getMessage("name.label")); TextField input = new TextField(); input.setPrefWidth(200.0); Button button = new Button(); button.setPrefWidth(200.0); JavaFXUtils.configure( button, (JavaFXAction) actionFor(controller, "sayHello").getToolkitAction()); Label output = new Label(); label.setPrefWidth(360.0); model.inputProperty().bindBidirectional(input.textProperty()); model.outputProperty().bindBidirectional(output.textProperty()); anchorPane.getChildren().addAll(label, input, button, output); setLeftAnchor(label, 14.0); setTopAnchor(label, 14.0); setLeftAnchor(input, 172.0); setTopAnchor(input, 11.0); setLeftAnchor(button, 172.0); setTopAnchor(button, 45.0); setLeftAnchor(output, 14.0); setTopAnchor(output, 80.0); Tab tab = new Tab("Java"); tab.setGraphic(new FontAwesomeIcon(FontAwesome.FA_COFFEE)); tab.setClosable(false); tab.setContent(anchorPane); parentView.getTabPane().getTabs().add(tab); }