Java how to make JLabel with vertical text?
2 answers
You can use the VerticalLabelUI class generated by dev: http://tech.chitgoks.com/2009/11/13/rotate-jlabel-vertically/
+5
source to share
You can create a method that converts your text to code HTML
like this:
public static String transformStringToHtml(String strToTransform) {
String ans = "<html>";
String br = "<br>";
String[] lettersArr = strToTransform.split("");
for (String letter : lettersArr) {
ans += letter + br;
}
ans += "</html>";
return ans;
}
Then if you use this method in a method setText
like: someLabel.setText(transformStringToHtml(someString));
where someString = "Test"
you get:
T
e
s
t
in your label.
0
source to share