Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8916201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:10:37+00:00 2026-06-15T05:10:37+00:00

I use a JEditorPane to render some HTML in a swing application. I use

  • 0

I use a JEditorPane to render some HTML in a swing application. I use a bullet point list <ul><li>...</li></ul> and I obtain overly large bullet points in the output. The same HTML chunk will show normal sized bullet points in a real browser.

I observed this on Windows 7 / JDK 7 and iirc also on Ubuntu and OpenJDK 1.7.0_09.

Is this known? Is there a way around it?

Working example:

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.WindowConstants;

/**
 *
 */
public class HTMLTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // create new frame
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        frame.setSize(500, 500);

        // create editor pane and fill with some html
        JEditorPane pane = new JEditorPane();
        pane.setContentType("text/html");
        pane.setEditable(false);
        pane.setText("<html><h1>Heading</h1>Text<ul><li>Bullet point</li></ul></html>");

        // add editor pane to frame and set frame visible
        frame.add(pane);
        frame.setVisible(true);
    }
}

P.S.: I am now using

ul {
    list-style-type: none;
    margin-left: 10px
}

in a css file and

<li>&bull; Item 1</li>

in the html to have a decent bullet point. Solution inspired by aterai.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:10:39+00:00Added an answer on June 15, 2026 at 5:10 am

    +1 @StanislavL and here is another example(use css list-style-image property):

    screenshot

    bullet.png: bullet.png

    import java.awt.*;
    import javax.swing.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    
    public class HTMLTest2 {
      public JComponent makeEditorPane(String bullet) {
        // create editor pane and fill with some html
        JEditorPane pane = new JEditorPane();
        pane.setContentType("text/html");
        pane.setEditable(false);
        if(bullet!=null) {
          HTMLEditorKit htmlEditorKit = (HTMLEditorKit)pane.getEditorKit();
          StyleSheet styleSheet = htmlEditorKit.getStyleSheet();
          //String u = getClass().getResource(bullet).toString();
          String u = "https://i.stack.imgur.com/jV29K.png";
          styleSheet.addRule(String.format("ul{list-style-image:url(%s);margin:0px 20px;", u));
          //styleSheet.addRule("ul{list-style-type:circle;margin:0px 20px;}");
          //styleSheet.addRule("ul{list-style-type:disc;margin:0px 20px;}");
          //styleSheet.addRule("ul{list-style-type:decimal;margin:0px 20px;}");
        }
        pane.setText("<html><h1>Heading</h1>Text<ul><li>Bullet point</li></ul></html>");
        return pane;
      }
      public JComponent makeUI() {
        JPanel p = new JPanel(new GridLayout(2,1));
        p.add(new JScrollPane(makeEditorPane(null)));
        p.add(new JScrollPane(makeEditorPane("bullet.png")));
        return p;
      }
      public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
          @Override public void run() {
            createAndShowGUI();
          }
        });
      }
      public static void createAndShowGUI() {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        f.getContentPane().add(new HTMLTest2().makeUI());
        f.setSize(320, 320);
        f.setLocationRelativeTo(null);
        f.setVisible(true);
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a swing client that renders HTML through the use of the JEditorPane
I want to create a simple test application with a JEditorPane displaying some HTML
I am trying to use JEditorPane to display some HTML text. For some reason
I'm using a JEditorPane to load some HTML content from a String so that
I am mixing a JavaFX controls to swing application. I want to use WebView
use Modern::Perl; use Algorithm::Permute; use List::AllUtils qw/uniq/; find_perms(1151); sub find_perms { my ($value) =
I have a JTextPane (or JEditorPane, I can use either no problem). How can
I would like to know how can I extend JEditorPane (or any other swing
We use Jeditor pane for displaying HTML text, but when we try to print
Use the grow() method to modify a rectangle to be twice as large. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.