Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Html Labels

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Supposedly you can do something like this:
String Text = ("<Html>Hello
I'm a Java-Html Label!" +
"I can change my font, and underline " +
"myself, supposedly, but i dont work " +
"how come? how can i get myself to " +
"work? ");
JLabel Label = new JLabel(Text);
Alas, this does not work, why?
 
Trailboss
Posts: 23211
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What flavor of "not work" are you experiencing?
 
martin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I compile it, run it, and it shows me the literal version of the string.
<Html> etc.
It has the little boxe's for the tabs and
such, it looks absolutely terrible. According to the Sun Java tutorial you can do this, exactly the way i showed ya.
Thanx in advance,
Martin
 
paul wheaton
Trailboss
Posts: 23211
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you are expecting to see underlining and stuff without specifying where the underlining happens?
 
martin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heh, no. I'm not an html god, but i do know
html. This is the full version of the program, you have a text area, you put in code click on a button and it changes the label to that html. Here is an example of some html i tried, and didnt work, and just showed me the literal version of it.
String initialText = "<html>\n" +
"Color and font test:\n" +
"
    \n" +
    "
  • red\n" +
    "
  • blue\n" +
    "
  • green\n" +
    "
  • italic\n" +
    "
  • bold\n" +
    "
  • \n";
    Now, this should some some nice different-colred text, etc. but it shows trash. Why?
 
paul wheaton
Trailboss
Posts: 23211
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks okay here - but of course we're viewing it through a browser.
I suppose what you are saying is that it should appear this way in java? This is news to me.
 
martin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you have to be an applet to do this, but the Sun Java Tutorial example is an application that makes a frame. So i have no idea.
 
Think of how dumb the average person is. Mathematically, half of them are EVEN DUMBER. Smart tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic