I put a string in a variabele and used it as text in a label. This works for shorter text, but my text is a few sentences long, so it ends with ...
instead of finishing my string. I'm working with JavaFX 1.0. Does anyone know how i can fix this?
Edit:
This is the code I wrote. I put the variable HandleidingDobbelsteen
in a stage in an other file.
import javafx.scene.text.Text;
import javafx.scene.text.Font;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import javafx.scene.control.Label;
package var DobbelsteenHandleiding = Label {
text: "Hier komt te staan wat de uitkomst van de dobbelsteen betekent."
translateX: 830
translateY: 245
width: 140
textWrap: true;
}
package var HandleidingDobbelsteen = Group {
content:[
DobbelsteenHandleiding,
Rectangle {
x: 825, y: 220
width: 150, height: 120
fill: null
stroke: Color.BLACK
strokeWidth: 1.3
},
Rectangle {
x: 825, y: 220
width: 150, height: 20
fill: Color.BLACK
},
Text {
font : Font {size: 18}
x: 845, y: 235
content: "De regels"
fill: Color.WHITE
},
]
}
The likely cause of your issue is that the
String
being used to set theLabel
'stextProperty
is longer than theLabel
is able to display. Without seeing your actual code, I have a couple of suggestions:First of all, make sure that your
Label
is wrapping its text:label.setWrapText(true);
Secondly, you should make sure that the
Label
is wrapped in a layout container that can handle a node that grows (not always necessary, but recommended). My recommendation is aVBox
:Again, there is some assumption here on the version of JavaFX you're actually using, but you could try this simple example to see if it works for you:
To confirm that
label.setWrapText(true);
actually makes a difference, here's the result of the above code without that line, complete with the elipses ("...") you're experiencing: