How to set the width of a Text element in JavaFX?

By: AnderRuiz Viewed: 153455 times  Printer Friendly Format    


Stack {
                    layoutInfo: LayoutInfo {
                        width: bind width;
                        height: bind height;
                    }
                    content: [Rectangle {
                            width: bind width, height: bind height
                            //fill: bind color;
                            fill: Color.GREEN
                            arcHeight: 20; arcWidth: 20;
                        }
                        Text {
                            font: Font {
                                size: 24
                            }
                            textAlignment: TextAlignment.CENTER;
                            wrappingWidth: width;
                            boundsType: TextBoundsType.VISUAL;
                            fill: Color.WHITE;
                            content: bind text;
                        }
                    ]
                }

wrappingWidth: Sets the maximun width of the text
boundsType: If you put the wrappingWidth var and you want to center a text you MUST set this var to VISUAL



Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial