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); }
private VBox Chat(){ VBox chat = new VBox(); chat.setPrefSize(400, 400); chat.setStyle("-fx-background-color:#333333;"); Label txt1 = new Label("Text1"); txt1.setTextFill(Color.WHITE); txt1.setPrefWidth(400); txt1.setAlignment(Pos.CENTER_LEFT); Label txt2 = new Label("Text2"); txt2.setTextFill(Color.WHITE); txt2.setPrefWidth(400); txt2.setAlignment(Pos.CENTER_RIGHT); chat.getChildren().addAll(txt1,txt2); return chat; }
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); }
name.setAlignment(Pos.CENTER_RIGHT); icon.setAlignment(Pos.CENTER_LEFT); icon.setMaxWidth(Double.MAX_VALUE); HBox.setHgrow(icon, Priority.ALWAYS);
sign.setAlignment(Pos.CENTER); System.out.print(sign);
private final Random random = new Random(); private final Color[] colors = { Color.RED, Color.GREEN, Color.BLUE, Color.YELLOW }; @Override public void start( final Stage primaryStage ) { HBox hbox = new HBox(); String str = "my-string-val"; for ( String s : str.split( "" ) ) { Label l = new Label( s ); l.setBorder( new Border( new BorderStroke( Color.BLACK, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT ) ) ); l.setBackground( new Background( new BackgroundFill( colors[random.nextInt( colors.length )], CornerRadii.EMPTY, Insets.EMPTY ) ) ); l.setPrefWidth( 20 ); l.setAlignment( Pos.CENTER ); l.setFont( font( "Arial", FontWeight.BOLD, 16 ) ); hbox.getChildren().add( l ); } final Scene scene = new Scene( hbox, 800, 600 ); primaryStage.setScene( scene ); primaryStage.show(); }
Label lblSecondWindow = new Label("This is the second window"); lblSecondWindow.setAlignment(Pos.TOP_LEFT); lblSecondWindow.autosize(); lblSecondWindow.setVisible(true); StackPane secondLayout = new StackPane(); secondLayout.getChildren().add(lblSecondWindow); Scene secondScene = new Scene(secondLayout, 300, 200); Stage secondStage = new Stage(); secondStage.setTitle("Please Wait"); secondStage.setScene(secondScene); secondStage.show(); try { Thread.sleep(1000); } catch (InterruptedException ex) { } // Stands for expensive operation (the whole try catch) secondStage.close();
Label label = new Label(String.valueOf(random.nextInt(rows * columns))); label.setMinSize(30, 30); label.setAlignment(Pos.CENTER); grid.add(label, colIdx, rowIdx); GridPane.setConstraints(label, colIdx, rowIdx, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
Label label = new Label(); label.setPrefSize(100, 50); label.setAlignment(Pos.CENTER);
displayedText.setAlignment(Pos.CENTER_RIGHT); directionIndicator.setContent("M10 0 L0 10 L0 0 Z"); directionIndicator.setFill(DEFAULT_SENDER_COLOR); displayedText.setAlignment(Pos.CENTER_LEFT); directionIndicator.setContent("M0 0 L10 0 L10 10 Z"); directionIndicator.setFill(DEFAULT_RECEIVER_COLOR);
counter.setAlignment(Pos.CENTER_RIGHT); counter.textProperty().bind(task.messageProperty()); counter.setStyle("-fx-border-color: forestgreen;");
headerLabel.setAlignment(Pos.CENTER_RIGHT); headerLabel.setMaxWidth(Double.MAX_VALUE); headerLabel.setMaxHeight(Double.MAX_VALUE);
label.setContentDisplay(ContentDisplay.CENTER); label.setTextFill(Color.WHITE); label.setAlignment(Pos.CENTER);
headerLabel.setAlignment(Pos.CENTER_RIGHT); headerLabel.setMaxWidth(Double.MAX_VALUE); headerLabel.setMaxHeight(Double.MAX_VALUE);
zombieLabel.setAlignment(Pos.CENTER); HBox zomBox = new HBox(); zomBox.getChildren().add(zombieLabel); indicateLabel.setAlignment(Pos.CENTER); HBox indBox = new HBox(); indBox.getChildren().add(indicateLabel);
clickCountLabel.setAlignment(Pos.CENTER);
content.setAlignment(Pos.CENTER); content.setPrefSize(200, 100); content.setStyle("-fx-font-size: 30px; -fx-background-color: " + webColor + ";");
label.setMaxWidth(Double.MAX_VALUE); label.setStyle("-fx-background-color: "+color+" ;"); label.setAlignment(Pos.CENTER); return label ;
clickCountLabel.setAlignment(Pos.CENTER); setPadding(new Insets(10));