List of usage examples for javafx.scene.control Label setMaxWidth
public final void setMaxWidth(double value)
From source file:photobooth.views.EmailPane.java
private void addLabel() { String text = Global.getPhrase("email_pane_text"); Label label = new Label(text); label.setWrapText(true);/*from w w w .j a va 2 s . c o m*/ label.setLayoutX(50); label.setLayoutY(150); label.setMaxWidth(700); label.setTextAlignment(TextAlignment.CENTER); label.setFont(new Font(40)); label.setTextFill(Color.web("#000")); this.getChildren().add(label); }
From source file:de.perdian.apps.tagtiger.fx.handlers.batchupdate.UpdateFileNamesFromTagsActionEventHandler.java
private Parent createLegendPane() { GridPane legendPane = new GridPane(); legendPane.setPadding(new Insets(5, 5, 5, 5)); int columnCount = 3; int currentRow = 0; int currentColumn = 0; for (UpdateFileNamesPlaceholder placeholder : UpdateFileNamesPlaceholder.values()) { StringBuilder placeholderText = new StringBuilder(); placeholderText.append("${").append(placeholder.getPlaceholder()).append("}: "); placeholderText.append(placeholder.resolveLocalization(this.getLocalization())); Label placeholderLabel = new Label(placeholderText.toString()); placeholderLabel.setMaxWidth(Double.MAX_VALUE); placeholderLabel.setPadding(new Insets(3, 3, 3, 3)); placeholderLabel.setAlignment(Pos.TOP_LEFT); legendPane.add(placeholderLabel, currentColumn, currentRow); GridPane.setFillWidth(placeholderLabel, Boolean.TRUE); GridPane.setHgrow(placeholderLabel, Priority.ALWAYS); currentColumn++;//from w ww.ja v a2 s .co m if (currentColumn >= columnCount) { currentRow++; currentColumn = 0; } } TitledPane legendTitlePane = new TitledPane(this.getLocalization().legend(), legendPane); legendTitlePane.setCollapsible(false); return legendTitlePane; }
From source file:calendarioSeries.vistas.NewSerieController.java
@FXML public void handleOk() { String tituloAux = titulo.getText().replaceAll(" ", "+").toLowerCase(); String toJson = readUrl(BASE + tituloAux + "&type=series" + "&r=json"); resultados.getChildren().clear();/*from w ww .j a va 2 s .c o m*/ try { JSONObject busqueda = new JSONObject(toJson); if (busqueda.getString("Response").equals("True")) { JSONArray res = busqueda.getJSONArray("Search"); resultados.setPrefRows(res.length()); for (int i = 0; i < res.length(); i++) { JSONObject resActual = new JSONObject(res.get(i).toString()); HBox resultadoActual = new HBox(50); resultadoActual.setMaxWidth(Double.MAX_VALUE); resultadoActual.setAlignment(Pos.CENTER_LEFT); ImageView posterActual = new ImageView(); try { Image image = new Image(resActual.getString("Poster")); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } catch (IllegalArgumentException e) { // System.out.println("Bad url"); Image image = new Image( MainApp.class.getResource("resources/no-image.png").toExternalForm()); posterActual.setImage(image); posterActual.setFitHeight(240); posterActual.setFitWidth(180); posterActual.setPreserveRatio(false); resultadoActual.getChildren().add(posterActual); } String details; String nomSerie = new String(resActual.getString("Title").getBytes(), "UTF-8"); String anoSerie = new String(resActual.getString("Year").getBytes(), "UTF-8"); if (nomSerie.length() > 15) { details = "%-12.12s...\t\t Ao: %-10s"; } else { details = "%-12s\t\t Ao: %-10s"; } details = String.format(details, nomSerie, anoSerie); Label elemento = new Label(details); elemento.setMaxWidth(Double.MAX_VALUE); elemento.setMaxHeight(Double.MAX_VALUE); resultadoActual.getChildren().add(elemento); posterActual.setId(resActual.getString("imdbID")); posterActual.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { ImageView clickedButton = (ImageView) event.getSource(); Stage stage = (Stage) clickedButton.getScene().getWindow(); Task task = new Task() { @Override protected Object call() throws Exception { mainController.mainApp.scene.setCursor(Cursor.WAIT); Serie toAdd = new Serie(clickedButton.getId()); boolean possible = true; for (Serie serie : mainController.getSeries()) { if (serie.equals(toAdd)) possible = false; } if (possible) mainController.getSeries().add(toAdd); try { mainController.populateImagenes(); mainController.showDetallesMes(mainController.getMesActual()); } catch (Exception e) { e.printStackTrace(); } finally { mainController.mainApp.scene.setCursor(Cursor.DEFAULT); return mainController.getSeries(); } } }; Thread th = new Thread(task); th.setDaemon(true); th.start(); stage.close(); } }); resultados.getChildren().add(resultadoActual); } } else { resultados.getChildren().add(new Label("La busqueda no obtuvo resultados")); } } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException ex) { Logger.getLogger(NewSerieController.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:io.bitsquare.gui.components.paymentmethods.SepaForm.java
private void addCountriesGrid(boolean isEditable, String title, List<CheckBox> checkBoxList, List<Country> dataProvider) { Label label = addLabel(gridPane, ++gridRow, title, 0); label.setWrapText(true);/*from w w w . j av a2 s.co m*/ label.setMaxWidth(180); label.setTextAlignment(TextAlignment.RIGHT); GridPane.setHalignment(label, HPos.RIGHT); GridPane.setValignment(label, VPos.TOP); FlowPane flowPane = new FlowPane(); flowPane.setPadding(new Insets(10, 10, 10, 10)); flowPane.setVgap(10); flowPane.setHgap(10); flowPane.setMinHeight(55); if (isEditable) flowPane.setId("flow-pane-checkboxes-bg"); else flowPane.setId("flow-pane-checkboxes-non-editable-bg"); dataProvider.stream().forEach(country -> { final String countryCode = country.code; CheckBox checkBox = new CheckBox(countryCode); checkBox.setUserData(countryCode); checkBoxList.add(checkBox); checkBox.setMouseTransparent(!isEditable); checkBox.setMinWidth(45); checkBox.setMaxWidth(45); checkBox.setTooltip(new Tooltip(country.name)); checkBox.setOnAction(event -> { if (checkBox.isSelected()) sepaAccount.addAcceptedCountry(countryCode); else sepaAccount.removeAcceptedCountry(countryCode); updateAllInputsValid(); }); flowPane.getChildren().add(checkBox); }); updateCountriesSelection(isEditable, checkBoxList); GridPane.setRowIndex(flowPane, gridRow); GridPane.setColumnIndex(flowPane, 1); gridPane.getChildren().add(flowPane); }
From source file:gov.va.isaac.gui.preferences.PreferencesViewController.java
public void aboutToShow() { // Using allValid_ to prevent rerunning content of aboutToShow() if (allValid_ == null) { // These listeners are for debug and testing only. They may be removed at any time. UserProfileBindings userProfileBindings = AppContext.getService(UserProfileBindings.class); for (Property<?> property : userProfileBindings.getAll()) { property.addListener(new ChangeListener<Object>() { @Override//from w w w . j a v a2 s . c om public void changed(ObservableValue<? extends Object> observable, Object oldValue, Object newValue) { logger.debug("{} property changed from {} to {}", property.getName(), oldValue, newValue); } }); } // load fields before initializing allValid_ // in case plugin.validationFailureMessageProperty() initialized by getNode() tabPane_.getTabs().clear(); List<PreferencesPluginViewI> sortableList = new ArrayList<>(); Comparator<PreferencesPluginViewI> comparator = new Comparator<PreferencesPluginViewI>() { @Override public int compare(PreferencesPluginViewI o1, PreferencesPluginViewI o2) { if (o1.getTabOrder() == o2.getTabOrder()) { return o1.getName().compareTo(o2.getName()); } else { return o1.getTabOrder() - o2.getTabOrder(); } } }; for (PreferencesPluginViewI plugin : plugins_) { sortableList.add(plugin); } Collections.sort(sortableList, comparator); for (PreferencesPluginViewI plugin : sortableList) { logger.debug("Adding PreferencesPluginView tab \"{}\"", plugin.getName()); Label tabLabel = new Label(plugin.getName()); tabLabel.setMaxHeight(Double.MAX_VALUE); tabLabel.setMaxWidth(Double.MAX_VALUE); Tab pluginTab = new Tab(); pluginTab.setGraphic(tabLabel); Region content = plugin.getContent(); content.setMaxWidth(Double.MAX_VALUE); content.setMaxHeight(Double.MAX_VALUE); content.setPadding(new Insets(5.0)); Label errorMessageLabel = new Label(); errorMessageLabel.textProperty().bind(plugin.validationFailureMessageProperty()); errorMessageLabel.setAlignment(Pos.BOTTOM_CENTER); TextErrorColorHelper.setTextErrorColor(errorMessageLabel); VBox vBox = new VBox(); vBox.getChildren().addAll(errorMessageLabel, content); vBox.setMaxWidth(Double.MAX_VALUE); vBox.setAlignment(Pos.TOP_CENTER); plugin.validationFailureMessageProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { if (newValue != null && !StringUtils.isEmpty(newValue)) { TextErrorColorHelper.setTextErrorColor(tabLabel); } else { TextErrorColorHelper.clearTextErrorColor(tabLabel); } } }); //Initialize, if stored value is wrong if (StringUtils.isNotEmpty(plugin.validationFailureMessageProperty().getValue())) { TextErrorColorHelper.setTextErrorColor(tabLabel); } pluginTab.setContent(vBox); tabPane_.getTabs().add(pluginTab); } allValid_ = new ValidBooleanBinding() { { ArrayList<ReadOnlyStringProperty> pluginValidationFailureMessages = new ArrayList<>(); for (PreferencesPluginViewI plugin : plugins_) { pluginValidationFailureMessages.add(plugin.validationFailureMessageProperty()); } bind(pluginValidationFailureMessages .toArray(new ReadOnlyStringProperty[pluginValidationFailureMessages.size()])); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { for (PreferencesPluginViewI plugin : plugins_) { if (plugin.validationFailureMessageProperty().get() != null && plugin.validationFailureMessageProperty().get().length() > 0) { this.setInvalidReason(plugin.validationFailureMessageProperty().get()); logger.debug("Setting PreferencesView allValid_ to false because \"{}\"", this.getReasonWhyInvalid().get()); return false; } } logger.debug("Setting PreferencesView allValid_ to true"); this.clearInvalidReason(); return true; } }; okButton_.disableProperty().bind(allValid_.not()); // set focus on default // Platform.runLater(...); } // Reload persisted values every time view opened for (PreferencesPluginViewI plugin : plugins_) { plugin.getContent(); } }
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.OrganizerImpl.java
private void initializeFilesTree() { folderTree.setOnMouseClicked(event -> handleFolderChange()); folderTree.setCellFactory(treeView -> { HBox hbox = new HBox(); hbox.setMaxWidth(200);//from w w w .j a va 2 s . co m hbox.setPrefWidth(200); hbox.setSpacing(7); FontAwesomeIconView openFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_OPEN_ALT); openFolderIcon.setTranslateY(7); FontAwesomeIconView closedFolderIcon = new FontAwesomeIconView(FontAwesomeIcon.FOLDER_ALT); closedFolderIcon.setTranslateY(7); Label dirName = new Label(); dirName.setMaxWidth(150); FontAwesomeIconView removeIcon = new FontAwesomeIconView(FontAwesomeIcon.REMOVE); Tooltip deleteToolTip = new Tooltip(); deleteToolTip.setText("Verzeichnis aus Workspace entfernen"); Button button = new Button(null, removeIcon); button.setTooltip(deleteToolTip); button.setTranslateX(8); return new TreeCell<String>() { @Override public void updateItem(String item, boolean empty) { super.updateItem(item, empty); if (item == null || empty) { setGraphic(null); setText(null); } else if (getTreeItem() instanceof FilePathTreeItem) { hbox.getChildren().clear(); dirName.setText(item); if (getTreeItem().isExpanded()) { hbox.getChildren().add(openFolderIcon); } else { hbox.getChildren().add(closedFolderIcon); } hbox.getChildren().add(dirName); TreeItem<String> treeItem = getTreeItem(); TreeItem<String> parent = treeItem != null ? treeItem.getParent() : null; if (parent != null && parent.equals(folderTree.getRoot())) { String path = ((FilePathTreeItem) getTreeItem()).getFullPath(); button.setOnAction(event -> handleDeleteDirectory(Paths.get(path))); hbox.getChildren().add(button); } setGraphic(hbox); } } }; }); }
From source file:gov.va.isaac.sync.view.SyncView.java
private void initGui() { root_ = new BorderPane(); root_.setPrefWidth(550);//www. j ava2 s. c om VBox titleBox = new VBox(); Label title = new Label("Datastore Synchronization"); title.getStyleClass().add("titleLabel"); title.setAlignment(Pos.CENTER); title.setMaxWidth(Double.MAX_VALUE); title.setPadding(new Insets(10)); titleBox.getChildren().add(title); titleBox.getStyleClass().add("headerBackground"); url_ = AppContext.getAppConfiguration().getCurrentChangeSetUrl(); String urlType = AppContext.getAppConfiguration().getChangeSetUrlTypeName(); String syncUsername = ExtendedAppContext.getCurrentlyLoggedInUserProfile().getSyncUsername(); if (StringUtils.isBlank(syncUsername)) { syncUsername = ExtendedAppContext.getCurrentlyLoggedInUser(); } url_ = syncService_.substituteURL(url_, syncUsername); Label info = new CopyableLabel("Sync using " + urlType + ": " + url_); info.setTooltip(new Tooltip(url_)); titleBox.getChildren().add(info); titleBox.setPadding(new Insets(5, 5, 5, 5)); root_.setTop(titleBox); VBox centerContent = new VBox(); centerContent.setFillWidth(true); centerContent.setPrefWidth(Double.MAX_VALUE); centerContent.setPadding(new Insets(10)); centerContent.getStyleClass().add("itemBorder"); centerContent.setSpacing(10.0); centerContent.getChildren().add(new Label("Status:")); summary_ = new TextArea(); summary_.setWrapText(true); summary_.setEditable(false); summary_.setMaxWidth(Double.MAX_VALUE); summary_.setMaxHeight(Double.MAX_VALUE); summary_.setPrefHeight(150.0); centerContent.getChildren().add(summary_); VBox.setVgrow(summary_, Priority.ALWAYS); pb_ = new ProgressBar(0.0); pb_.setPrefHeight(20); pb_.setMaxWidth(Double.MAX_VALUE); centerContent.getChildren().add(pb_); root_.setCenter(centerContent); //Bottom buttons HBox buttons = new HBox(); buttons.setMaxWidth(Double.MAX_VALUE); buttons.setAlignment(Pos.CENTER); buttons.setPadding(new Insets(5)); buttons.setSpacing(30); Button cancel = new Button("Close"); cancel.setOnAction((action) -> { if (running_.get()) { addLine("Cancelling..."); cancel.setDisable(true); cancelRequested_ = true; } else { cancel.getScene().getWindow().hide(); root_ = null; } }); buttons.getChildren().add(cancel); Button action = new Button("Synchronize"); action.disableProperty().bind(running_); action.setOnAction((theAction) -> { summary_.setText(""); pb_.setProgress(-1.0); running_.set(true); Utility.execute(() -> sync()); }); buttons.getChildren().add(action); cancel.minWidthProperty().bind(action.widthProperty()); running_.addListener(change -> { if (running_.get()) { cancel.setText("Cancel"); } else { cancel.setText("Close"); } cancel.setDisable(false); }); root_.setBottom(buttons); }
From source file:org.sleuthkit.autopsy.timeline.ui.AbstractVisualization.java
/** add a {@link Label} node to the branch container for the decluttered * axis labels//w ww . ja v a 2s . c om * * @param labelText the string to add * @param labelWidth the width of the space to use for the label * @param labelX the horizontal position in the partPane of the text */ private synchronized void assignBranchLabel(String labelText, double labelWidth, double labelX) { Label label = new Label(labelText); label.setAlignment(Pos.CENTER); label.setTextAlignment(TextAlignment.CENTER); label.setFont(Font.font(10)); //use a leading ellipse since that is the lowest frequency part, //and can be infered more easily from other surrounding labels label.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS); //force size label.setMinWidth(labelWidth); label.setPrefWidth(labelWidth); label.setMaxWidth(labelWidth); label.relocate(labelX, 0); if (labelX == 0) { // first label has no border label.setStyle("-fx-border-width: 0 0 0 0 ; -fx-border-color:black;"); // NON-NLS } else { // subsequent labels have border on left to create dividers label.setStyle("-fx-border-width: 0 0 0 1; -fx-border-color:black;"); // NON-NLS } branchPane.getChildren().add(label); }
From source file:org.sleuthkit.autopsy.timeline.ui.AbstractVisualizationPane.java
/** * add a {@link Label} node to the branch container for the decluttered axis * labels/* w w w . java 2 s . c o m*/ * * @param labelText the string to add * @param labelWidth the width of the space to use for the label * @param labelX the horizontal position in the partPane of the text */ private synchronized void assignBranchLabel(String labelText, double labelWidth, double labelX) { Label label = new Label(labelText); label.setAlignment(Pos.CENTER); label.setTextAlignment(TextAlignment.CENTER); label.setFont(Font.font(10)); //use a leading ellipse since that is the lowest frequency part, //and can be infered more easily from other surrounding labels label.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS); //force size label.setMinWidth(labelWidth); label.setPrefWidth(labelWidth); label.setMaxWidth(labelWidth); label.relocate(labelX, 0); if (labelX == 0) { // first label has no border label.setStyle("-fx-border-width: 0 0 0 0 ; -fx-border-color:black;"); // NON-NLS //NOI18N } else { // subsequent labels have border on left to create dividers label.setStyle("-fx-border-width: 0 0 0 1; -fx-border-color:black;"); // NON-NLS //NOI18N } branchPane.getChildren().add(label); }
From source file:org.sleuthkit.autopsy.timeline.ui.AbstractTimelineChart.java
/** * Add a Label Node to the contextual label container for the decluttered * axis labels.//from w w w .ja va 2s. com * * @param labelText The String to add. * @param labelWidth The width, in pixels, of the space to use for the label * @param labelX The horizontal position, in pixels, in the specificPane * of the text */ private synchronized void addContextLabel(String labelText, double labelWidth, double labelX) { Label label = new Label(labelText); label.setAlignment(Pos.CENTER); label.setTextAlignment(TextAlignment.CENTER); label.setFont(Font.font(10)); //use a leading ellipse since that is the lowest frequency part, //and can be infered more easily from other surrounding labels label.setTextOverrun(OverrunStyle.LEADING_ELLIPSIS); //force size label.setMinWidth(labelWidth); label.setPrefWidth(labelWidth); label.setMaxWidth(labelWidth); label.relocate(labelX, 0); if (labelX == 0) { // first label has no border label.setBorder(null); } else { // subsequent labels have border on left to create dividers label.setBorder(ONLY_LEFT_BORDER); } contextLabelPane.getChildren().add(label); }