Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

new line character in a JLabel, does it work?  RSS feed

 
luc comeau
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i feel retarded for posting this, but meh thats what its here for eh!haha

Anyways i have a JLabel with a sentence in it and its added to a gridlayout beside a jslider, but the text is so long that it only prints what it can so that the label and the slider have equal length in the panel.So i figured ill just put a new line character in the JLabels text so that it puts the labels text on two lines....no dice.Im programing on windows i tryed "\n" tryed "\r\n" , although they were recognized as special characters the didnt put the text after it on a new line, just continue it.So im wondering if its possible to even put a new line character in the text of a JLabel?

To test if the new lines work normally i did a
System.out.print("this text should \r\n go on a new line");

and i got

this text should
go on a new line

so im not quite sure whats going on..Im sure its simple i just dont know the answer.Any suggestions.
thanks
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously newline does not work, but Swing components can render HTML:
 
luc comeau
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works for me thanks, i didnt know that they could have html in them, guess ima noob
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!