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

JOptionPane.getMaxCharactersPerLineCount() does not work well with HTML

XMLWordPrintable

      J2SE Version (please include all output from java -version flag):
        java version "1.6.0-beta2"
        Java(TM) SE Runtime Environment (build 1.6.0-beta2-b75)
        Java HotSpot(TM) Client VM (build 1.6.0-beta2-b75, mixed mode, sharing)

      Does this problem occur on J2SE 1.4.x or 5.0.x ? Yes / No (pick one)
        Yes

      Operating System Configuration Information (be specific):
        Microsoft Windows 2000 [Version 5.00.2195]

      Hardware Configuration Information (be specific):
        Pentium 4

      Bug Description:
        JOptionPane.getMaxCharactersPerLineCount() does not work at all well
       with HTML
        After running the code we can see that the OptionPane is splitting the
        HTML in the middle of tags, when in should be ignoring the tags when
        counting characters.

      import javax.swing.*;

      public class Test {
        public static void main(String[] args) {
          new JOptionPane("<html><body style=\"font-family: 'Times New Roman';
      font-size: 14pt\">" +
               "<center><font color=red>Extremely long message that is so wide
      that it wont fit in " +
               "the width of a normal screen, and hence it should be wrapped
      so that it does not appear" +
               " all on one extremely long line</font></center></body></html>") {
            public int getMaxCharactersPerLineCount() {
              return 100;
            }
          }.createDialog(null, "Test").setVisible(true);
          System.exit(0);
        }
      }

            mlapshin Mikhail Lapshin (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: