开发者

Best way to add a String in a JFrame

which is the best way to add format开发者_运维知识库ed string in jframe. Previously I was trying to add jlabel


If you want to display some text in a window, yes, adding a JLabel to your JFrame is fine.

Just create an instance of the font you want and assign it to the JLabel using setFont.

Here is a code samle (taken from here):

Font font = new Font("Jokerman", Font.PLAIN, 35);
JLabel textLabel = new JLabel(textMessage);
textLabel.setFont(font);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜