label.setPrefWidth(300);
label.setPrefWidth(3); return label;
Label lbl = new Label("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"); lbl.setPrefWidth(50); lbl.setWrapText(true); MenuItem menuItem = new MenuItem(); menuItem.setGraphic(lbl); contextMenu.getItems().add(menuItem);
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; }
private static Label createNoEllipsisLabel(String pText) { Label label = new Label(pText); double width = computeTextWidth(label.getFont(), pText, 0); label.setPrefWidth(width); label.setMinWidth(width); return label; } private static final TextLayout layout = Toolkit.getToolkit().getTextLayoutFactory().createLayout(); private static double computeTextWidth(Font font, String text, double wrappingWidth) { layout.setContent(text != null ? text : "", font.impl_getNativeFont()); layout.setWrapWidth((float)wrappingWidth); return layout.getBounds().getWidth(); }
textLabel.setPrefWidth(360);
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(); }
@Override public void start(Stage primaryStage) { Label label=new Label("Text"); label.getStyleClass().add("copyable-label"); label.setPrefWidth(100); TextField textField=new TextField("Text"); textField.setEditable(false); textField.getStyleClass().add("copyable-label"); textField.setPrefWidth(100); textField.setMinWidth(100); textField.setMaxWidth(100); VBox root = new VBox(20,label,textField, new Button("Ok")); root.setStyle("-fx-background-color: #ccc;"); root.setAlignment(Pos.CENTER); Scene scene = new Scene(root, 300, 250); scene.getStylesheets().add(getClass().getResource("root.css").toExternalForm()); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
sample.setPrefWidth(150); sample.setAlignment(Pos.CENTER); USCS.setPrefWidth(150); USCS.setAlignment(Pos.CENTER); ColorField.setPrefWidth(150); ColorField.setAlignment(Pos.CENTER); DensityLabel.setPrefWidth(150); DensityLabel.setAlignment(Pos.CENTER); MoistureField.setPrefWidth(150); MoistureField.setAlignment(Pos.CENTER); startElevationField.setPrefWidth(150); startElevationField.setAlignment(Pos.CENTER); endElevationField.setPrefWidth(150); endElevationField.setAlignment(Pos.CENTER); BlowCount6Field.setPrefWidth(150); BlowCount6Field.setAlignment(Pos.CENTER); BlowCount12Field.setPrefWidth(150); BlowCount12Field.setAlignment(Pos.CENTER); BlowCount18Field.setPrefWidth(150); BlowCount18Field.setAlignment(Pos.CENTER);
Label l = new Label(); l.setPrefHeight(100); l.setPrefWidth(100); l.getStyleClass().add("box");
promptMessage.setGraphic(alertImage); promptMessage.setWrapText(true); promptMessage.setPrefWidth(350);
symbol.setPrefWidth(25); //Sum of the values used by the "arrow" region
playTime.setPrefWidth(130); playTime.setMinWidth(50); mediaBar.getChildren().add(playTime);
columnTitle.setPrefWidth(125); columnTitle.setPrefHeight(50); columnTitle.setWrapText(true);