I use HTML to put text into a JButton. In this way I can play with colors and text size. What I do not like is the distance from the left border of the button and the text (this separation is too large). Is there a way to decrease this distance? I think it should be some parameter in the style of the HTML code.
Sample of the code:
JButton btn = new JButton("<html><span style='color:#000000; font-size: 11pt;'>" + label + "</span></html>");
I would recommend doing this programmatically rather than attempting to do it with HTML as you’ll be more likely to see consistent results across platforms.
Then you can customise the font size by either overriding paintComponent (more work) or modifying the FontUIResource object at start-up (although this will affect the font size of all buttons); e.g.