nicky
nicky

Reputation: 3908

Best way to add a String in a JFrame

which is the best way to add formated string in jframe. Previously I was trying to add jlabel

Upvotes: 2

Views: 9971

Answers (1)

Oded
Oded

Reputation: 499092

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);

Upvotes: 2

Related Questions