Programming Tutorials

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

By: AnderRuiz in Java Tutorials on 2010-07-31  

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

Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Java )

Latest Articles (in Java)