Bug in html-"<pre>" command in JEditorPane of OpenJDK

theUser BL theuserbl at hotmail.com
Fri Jun 20 08:23:39 UTC 2014


As I mentioned at
http://mail.openjdk.java.net/pipermail/distro-pkg-dev/2014-March/026907.html
there is a bug, that all reserved word in the "Source Code"-tabs of the SwingSet2demo looks like all other words.

And to Andrew who have answered: I have tested it with all OpenJDK-binaries I have. Last time I have again tested it, with the newest Zulu-OpenJDK binaries, and the bug still exists there.

I have now looked more special at this bug and find out, that it osn't so, that the reserved words are not written bold.
Here an example program I have created. Then you can test, if the bug still exists in the current OpenJDK:
-------------------------------------------------
import java.awt.*;
import javax.swing.*;

public class Test {
  public static void main(String[] args) {
    String text = "This <font color=red>is</font> a <b>different</b> test.";
    String s1 = "<html>" + text + "</html>";
    String s2 = "<html><pre>" + text + "</pre></html>";
    JFrame f = new JFrame("Mein Fenster");
    JPanel p = new JPanel();
   
    JLabel l1 = new JLabel(s1);
    l1.setFont(new Font("Serif", Font.PLAIN, 13));
    p.add(l1);
    JLabel l2 = new JLabel(s2);
    l2.setFont(new Font("Serif", Font.PLAIN, 13));
    p.add(l2);
    JEditorPane e1 = new JEditorPane("text/html", s1);
    e1.setFont(new Font("Serif", Font.PLAIN, 13));
    p.add(e1);
    JEditorPane e2 = new JEditorPane("text/html", s2);
    e2.setFont(new Font("Serif", Font.PLAIN, 13));
    p.add(e2);
    
    f.add(p);    
    f.pack();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
  }
}
------------------------------------------------------------------------

The first three text-strings (JLabel without <pre>, JLabel with <pre> and JEditorPane without <pre>) looking with Oracles Java and OpenJDK exactly the same.
But the third text-string (JEditorPane with <pre>)  have in OpenJDK the complete text written in bold. In Oracles Java, it is only the word "different", which is bold written.

Greatings
theuserbl
 		 	   		  


More information about the distro-pkg-dev mailing list