📜 ⬆️ ⬇️

Swing + HTML / CSS = Profit?

Did you have to embed HTML in Swing components? How much and in what quantities Swing is friendly with HTML / CSS is poorly documented and poorly documented.

You can say for sure that the code must comply with the doctype HTML 4.01 Transitional. It is important to understand how much Swing supports CSS. This will help us to the corresponding section JavaDoc.

In addition, you, of course, can not do without SwingHTMLPreview - a small utility that allows you to watch on the fly how your code is rendered in the Swing component.
')
But even with this set, there may be problems. Below are the ones that I managed to find during the work on the task.

HTML problems


Meta tags

Meta tag automatically kills HTML rendering in Swing-component - encoding in HTML won't work.

title

The <title></title> in some versions of Java may render this icon: > .
The same situation can occur when using an empty paragraph.

CSS issues


Inheritance

HTML in Swing has problems with inheritance. Absolutely not inherited font sizes.
Also there is a problem with the inheritance of flowers. For example, in the case of this code: <a href="URL"><code></code></a> - the text will be the color of the link, even if a code different color is specified for a code .

Colors

Swing does not understand abbreviated color indications in CSS (or rather, understands, but not enough), it means that you need to use the full name of the color, even if it asks to shorten it.
Well and appropriately, the CSS code intended for the Swing component should not be minified.

Source: https://habr.com/ru/post/83935/


All Articles