List of usage examples for javafx.scene.layout HBox setMaxWidth
public final void setMaxWidth(double value)
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 ww w . j ava2 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: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); hbox.setPrefWidth(200);//from w ww. j a v a2 s.c o m 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);/* w ww. ja v a 2s. co m*/ 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); }