0

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

MY CODES

Jakub Matczak
  • 15,341
  • 5
  • 46
  • 64
AJ AJ
  • 27
  • 3
  • 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
  • 1
    Possible duplicate of [Newline in JLabel](https://stackoverflow.com/questions/1090098/newline-in-jlabel) – tobias_k Aug 08 '17 at 13:43

3 Answers3

0

You can do something like this:

JLabel l = new JLabel("<html>pikachu<br>Doraemon </html>", SwingConstants.CENTER);
Chetan chadha
  • 558
  • 1
  • 4
  • 19
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
0

I think you need to change your code like this fr.setLayout(new GridLayout(2,1));

Jackeyzhe
  • 51
  • 5