Java – swing component: vertical text problem

If I have a button like the one in this image:

http://www.freeimagehosting.net/image.php?4cd775814c.png

How can I make the text display vertically? If in

j
B
u
t
t
o
n
1

I want to know how to do the same thing for jlabel I'm sure there must be a better way than creating as many tags as possible, because there are characters in the string yes?

Edit: how do I insert an image into my post? The image button displays the image in the preview section, but when I actually publish the data, I only return some text, just like the label screwed up

Solution

You can use HTML for JButton or jlabel therefore

button = new JButton("<html>J<br>b<br>u<br>t<br>t<br>o<br>n<br>1</html>");

A trick you should do

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>