I am trying to display a complex string in a Swing JButton using HTML/CSS. I am using CSS1 attributes, which is supported by Swing. The problem is that the following causes the button title to break into 3 separate lines rather than a single line:
javax.swing.JButton("<html><div style='display:inline;'>regular </div><div style='background-color:#336699;color:#fff;display:inline;'>special</div><div style='display:inline;'> regular again");

Note that the said string works great in a browser webpage, generating a single line (no line breaks):

I tried using “float:left” and “display:inline-block” – these also have no visible effect.
Anyone have an idea why this happens and what can be done?
Please limit your answers to HTML/CSS as I do not wish to implement a special L&F or class for this issue.
Well traditionally
<span>is just like a<div>except it defaults to inline display. I’d try that first before messing with much else.EDIT:
Ok so I played around with this a bit the following html works for me: