Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4827083

JLabel HTML interprets Java comments

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.1
    • client-libs



      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)
      ======================================================================

            idk Igor Kushnirskiy (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: