• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

new line character in a JLabel, does it work?

 
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
works for me thanks, i didnt know that they could have html in them, guess ima noob
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic