Math series mapping in JLabel

How can I show math series in JLabel?

Now I am doing it this way using String with HTML tags.

String s = "<html>&Sigma;<sup>N</sup><sub>i = 0</sub> x <sub>i</sub></html>";

Result: enter image description here

Is there a better way to do this? Because the output is very ugly. Usually Nshould be above sigma and i = 0below.

+3
source share
2 answers

A more convenient way to do this is to use a third-party library to render Latex code in Java.

There are several of them, for example JLatexMath , here is an example .

For example, using the program in this example, your total might look like this:

example 1

Or like this:

example 2

+2
source

, .

String s = "<html><table border='0'><tr>"
            + "<td style='font-size: larger'>&Sigma;</td>"
            + "<td style='font-size: smaller'>N<br>i = 0</td>"
            + "<td> x <sub>i</sub></td>"
            + "</tr></table>"
+1

All Articles