caption.setMaxWidth(220); caption.setWrapText(true); caption.setTextAlignment(TextAlignment.CENTER);
Label label = new Label("Some\ntext"); label.setGraphic(new ImageView(getClass().getResource("/images/Folder-icon.png").toExternalForm())); label.setMaxWidth(Double.POSITIVE_INFINITY); label.setMaxHeight(Double.POSITIVE_INFINITY); label.setStyle("-fx-border-color: blue;");
label.setMaxWidth(W - 20); label.setWrapText(true);
label.setMaxWidth(250); label.setWrapText(true);
Label label = new Label("Your long text here"); label.setMaxWidth(180); label.setWrapText(true);
Label errorLabel = new Label("Hello Hans"); errorLabel.setStyle("-fx-background-color: red"); Label warningLabel = new Label("HEEELLLOOOOOOOOOOOOOOOOOOOOOOOOO"); warningLabel.setStyle("-fx-background-color: orange"); warningLabel.setMaxWidth(Double.MAX_VALUE); errorLabel.setMaxWidth(Double.MAX_VALUE);
Label label = new Label("This text should wrap because it is too long"); label.setMaxWidth(150); label.setWrapText(true);
final Label title = new Label("Some text"); title.setMaxWidth(Double.MAX_VALUE); title.setAlignment(Pos.CENTER);
void testLabelPlains1(VBox box) { box.setFillWidth(true); Label first = new Label("first"); first.setAlignment(Pos.CENTER); first.setMaxWidth(Double.MAX_VALUE); first.setMaxHeight(Double.MAX_VALUE); VBox.setVgrow(first, Priority.ALWAYS); box.getChildren().addAll(first); }
label.setMaxWidth(Long.MAX_VALUE);
void testLabelPlains2(VBox box) { box.setFillWidth(true); Label first = new Label("first"); first.setAlignment(Pos.CENTER); first.setMaxWidth(Double.MAX_VALUE); first.setMaxHeight(Double.MAX_VALUE); VBox.setVgrow(first, Priority.ALWAYS); first.heightProperty().addListener(p -> { first.setFont(first.getFont().font(first.getHeight()*0.7)); }); box.getChildren().addAll(first); }
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.stage.Stage; public class HBoxExample extends Application { @Override public void start(Stage primaryStage) { HBox hbox = new HBox(); Label label = new Label("Label"); Button button = new Button("Button"); HBox.setHgrow(label, Priority.ALWAYS); label.setMaxWidth(Double.MAX_VALUE); hbox.getChildren().addAll(label, button); primaryStage.setScene(new Scene(hbox, 350, 75)); primaryStage.show(); } public static void main(String[] args) { launch(args); } }
icon.setMaxWidth(Double.MAX_VALUE); HBox.setHgrow(icon, Priority.ALWAYS); cell.getChildren().add(icon);
Label label = new Label("Titled Pane Header"); label.setMaxWidth(Double.MAX_VALUE);
label.setMaxWidth(Double.MAX_VALUE); HBox.setHgrow(label, Priority.ALWAYS);
headerLabel.setWrapText(true); headerLabel.setAlignment(Pos.CENTER_RIGHT); headerLabel.setMaxWidth(Double.MAX_VALUE); headerLabel.setMaxHeight(Double.MAX_VALUE); grid.add(headerLabel, 1, 0);
headerLabel.setWrapText(true); headerLabel.setAlignment(Pos.CENTER_RIGHT); headerLabel.setMaxWidth(Double.MAX_VALUE); headerLabel.setMaxHeight(Double.MAX_VALUE); grid.add(headerLabel, 1, 0);
label.setMaxWidth(WIDTH); label.setWrapText(true); box.getChildren().add(label);
.otherwise("WebView does not have the focus.") ); focusLabel.setMaxWidth(Double.MAX_VALUE); focusLabel.setStyle("-fx-background-color: coral; -fx-padding: 5;");
Label label = new Label(); VBox.setVgrow(label, Priority.ALWAYS); label.setMaxWidth(Double.MAX_VALUE); label.setStyle("-fx-background-color: "+color+" ;"); label.setAlignment(Pos.CENTER);