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);
精彩评论