The Special One
The Special One

Reputation: 497

Reading HTML file to view in JEditorPane

I have a Java program which prints to a HTML file. Another method reads in this file and prints it to the editor pane.

My problem is that the color orange doesn't work. My code is as follows:

print.println("<html><p><br><font color=\"orange\">");

When I pass this html file into the editor pane all the colors are right. Red, yellow and blue all work but orange doesn't (I have also tried replacing orange with pink etc but no luck). If I change the orange to say blue it works fine. When I open it up as a HTML file on the web the text that I want in orange is in orange and works fine. Help?

Also all the indenting is fine but when it gets near the end, it moves to the right. For Example:

abc 0
bcd 1
vde 1
def 2
...
swe 7      
    dfr 8            
              ..................................................... ert 3

Where ert 3 is the last string that needs to be printed. But it manages to fit all the text in the box.


Edit: Thanks for the help for the first part. Any ideas about the bottom part?

Upvotes: 1

Views: 1790

Answers (3)

l_39217_l
l_39217_l

Reputation: 2110

HTML in swing is not up to standard.

Take a look at this component https://xhtmlrenderer.dev.java.net/

Upvotes: 0

Fabian Steeg
Fabian Steeg

Reputation: 45714

The JEditorPane does not support all the things a modern browser supports. Soon, there will be a JWebPane component, which will provide full WebKit-based HTML support.

Upvotes: 1

Peter
Peter

Reputation: 5798

Orange is not working because its not a default html word

http://www.handleidinghtml.nl/divers/kleuren/schermafdrukken/16kleuren.gif

show the 16 default colors.

Most browsers however support other colors but java only supports HTML 3.2

read all on HTMl and swing in http://java.sun.com/docs/books/tutorial/uiswing/components/html.html

Upvotes: 2

Related Questions