0

I was wondering if it was possible to put chemical formulas ( SUB and SUP characters) into a Label content like:

enter image description here

Mike Laren
  • 7,768
  • 17
  • 48
  • 69
Thomas
  • 170
  • 11

1 Answers1

0

Here a solution using jlatexmath:

private void createGraphic(String textValue, Color color) {
    TeXFormula tex = new TeXFormula(textValue);
    java.awt.Image awtImage = tex.createBufferedImage(TeXConstants.STYLE_TEXT, 12, color, null);
    Image fxImage = SwingFXUtils.toFXImage((BufferedImage) awtImage, null);
    label.setGraphic(new ImageView(fxImage));
}
Tom
  • 15,514
  • 17
  • 42
  • 51
Thomas
  • 170
  • 11
  • I've added a link to the mentioned library. Please check if it is really the library you meant. – Tom Jun 10 '15 at 15:26