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

JEditorPane shows large HTML unordered list bullets

    Details

    • Subcomponent:
    • Resolved In Build:
      b14
    • CPU:
      x86_64
    • OS:
      generic

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Linux 4.8.0-53-generic #56~16.04.1-Ubuntu SMP Tue May 16 01:18:56 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      When displaying an HTML unordered list in a JEditorPane, the bullets generated by <li> looks larger than needed relative to text font size. See screenshot: https://www.dropbox.com/s/onv6v5xzutnvuyz/large-text-bullets.png?dl=0

      Related question: https://stackoverflow.com/questions/13626531/swing-html-rendering-shows-very-large-bullet-point

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached ListBullets class.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Unordered list bullets are a bit smaller than current ones. Thus, it will look more consistent with text.
      ACTUAL -
      Unordered list bullets look larger than needed relative to text font size.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;

      public class ListBullets {

          private static String getHtml() {
              return "<html><body>" +
                      "<ul>" +
                      "<li>Text</li>" +
                      "</ul>" +
                      "</body></html>";
          }

          private static Component createHtmlViewer() {
              JEditorPane editorPane = new JEditorPane();
              editorPane.setEditable(false);
              editorPane.setContentType("text/html");
              editorPane.setText(getHtml());
              return new JScrollPane(editorPane);
          }

          private static void createAndShowGUI() {
              JFrame frame = new JFrame("List Bullets");
              frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
              frame.add(createHtmlViewer());
              frame.pack();
              frame.setVisible(true);
          }

          public static void main(String[] args) {
              SwingUtilities.invokeLater(ListBullets::createAndShowGUI);
          }
      }

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

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psadhukhan Prasanta Sadhukhan
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: