Reputation: 4413
I wanted to take a text (javafx.scene.text) and put it on a polygon.
I tried it with a Group (javafx.scene.group) by trying this tutorial: tutorial on stackoverflow
This doesn't work with the text.setClip(Polygon).
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at ch.berufsbildungscenter.notiztool.gui.control.BbcPolygon$1.run(BbcPolygon.java:33)
at com.sun.javafx.application.PlatformImpl$6$1.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl$6$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(Unknown Source)
at com.sun.glass.ui.win.WinApplication$4$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Is there another way to get a Text onto a polygon?
Thanks Peace
Upvotes: 0
Views: 958
Reputation: 608
setClip() has different purpose. You can check the documentation
To easily put Text on a Polygon or any other node, you can use javafx.scene.layout.StackPane like this:
StackPane stack=new StackPane();
stack.getChildren().add(polygonInstance);
stack.getChildren().add(textInstance);
The node last added will be on top.
Upvotes: 2