hello I know this was dumb question but may I ask how to make another line in JLabel ? Or to make the label Doraemon print on the second line? Thank you in advanced
Asked
Active
Viewed 150 times
0
-
Welcome to Stack Overflow, please read https://stackoverflow.com/help/how-to-ask and then update your question to be a valid question. – Barkermn01 Aug 08 '17 at 13:34
-
1Possible duplicate of [Newline in JLabel](https://stackoverflow.com/questions/1090098/newline-in-jlabel) – tobias_k Aug 08 '17 at 13:43
3 Answers
0
You can do something like this:
JLabel l = new JLabel("<html>pikachu<br>Doraemon </html>", SwingConstants.CENTER);

Chetan chadha
- 558
- 1
- 4
- 19
-
Thank you for your suggestion but there's nothings changes happened in the output :( I tried what you have said – AJ AJ Aug 08 '17 at 13:38
-
Please refer to this link : https://stackoverflow.com/questions/1090098/newline-in-jlabel – Chetan chadha Aug 08 '17 at 13:40
0
You need to use one of the Layout Managers, or if you set the layout manager to null by writing
fr.setLayout(null);
then you should set the bounds correctly
lbl.setBounds( , , , ,)
and set the paramaters on how far from the top each label should be
the first paramater sets how far from the left and the second from the top. The last 2 set the size of the label.

isaace
- 3,336
- 1
- 9
- 22