问题
i need to make a vertical JLabel
- a JLabel
which shows it's text vertically- i searched google but i didn't find a good answer. how to do that?

回答1:
You could use the class VerticalLabelUI created by a dev: http://tech.chitgoks.com/2009/11/13/rotate-jlabel-vertically/
回答2:
You can create a method that will transform your text into an HTML
code 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;
}
Afterwards, if you'll use this method in a setText
method like this: someLabel.setText(transformStringToHtml(someString));
where someString = "Test"
you will receive:
T
e
s
t
in your label.
来源:https://stackoverflow.com/questions/14777926/java-how-to-make-a-jlabel-with-vertical-text