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
  • 8,028
  • 17
  • 51
  • 70
Thomas
  • 170
  • 1
  • 12

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
  • 16,842
  • 17
  • 45
  • 54
Thomas
  • 170
  • 1
  • 12
  • 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