JDK-4827083 : JLabel HTML interprets Java comments
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.1
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: linux
  • CPU: x86
  • Submitted: 2003-03-04
  • Updated: 2003-03-10
  • Resolved: 2003-03-10
Description

Name: jk109818			Date: 03/04/2003


FULL PRODUCT VERSION :
java version "1.4.1_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_02-b06)
Java HotSpot(TM) Client VM (build 1.4.1_02-b06, mixed mode)


FULL OS VERSION :
Linux machinename 2.4.18 #1 Tue Sep 3 18:31:07 BST 2002 i686 unknown unknown GNU/Linux


A DESCRIPTION OF THE PROBLEM :
If I try to use HTML text on a JLabel, but my text (after the "<html>") begins with a Java comment, no text appears until after the first HTML tag.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
; cat test.java
import java.awt.*;
import javax.swing.*;
public class test {
    public static void main(String[] args) {
        JFrame f = new JFrame();
        f.getContentPane().setLayout(new BorderLayout());
        f.getContentPane().add(new JLabel("<html>// this won't appear <font color=red>but this will</font> which is odd."), BorderLayout.CENTER);
        f.setSize(400, 400);
        f.setVisible(true);
    }
}
; javac test.java && java test

EXPECTED VERSUS ACTUAL BEHAVIOR :
A label saying "// this won't appear but this will which is odd.".
A label saying "but this will which is odd.".

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.*;
public class test {
    public static void main(String[] args) {
        JFrame f = new JFrame();
        f.getContentPane().setLayout(new BorderLayout());
        f.getContentPane().add(new JLabel("<html>// this won't appear <font color=red>but this will</font> which is odd.</html>"), BorderLayout.CENTER);
        f.setSize(400, 400);
        f.setVisible(true);
    }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
If you say "<html><body>// this won't...", then it works as expected. If this
is how it's supposed to behave, then the documentation (and tutorial!) needs to make this clear.
(Review ID: 181986) 
======================================================================

Comments
EVALUATION Name: ik75403 Date: 03/10/2003 This not a bug. The html is wrong. Try this: --- import java.awt.*; import javax.swing.*; public class test { public static void main(String[] args) { JFrame f = new JFrame(); f.getContentPane().setLayout(new BorderLayout()); f.getContentPane().add(new JLabel("<html><body> // this won't appear <font color=red>but this will</font> which is odd."), BorderLayout.CENTER); f.setSize(400, 400); f.setVisible(true); } } -- I have added the <body> tag and the test exanple works perefectly well Closing as not a bug ======================================================================
2004-06-11