Running swing application in javaFX

前端 未结 4 1972
花落未央
花落未央 2020-12-20 00:17

I have a code that work perfectly on Swing but I want to integrate it on javaFX. I know that I must use SwingNode but the code dosen\'t work in javaFX. this is .jar of libra

4条回答
  •  渐次进展
    2020-12-20 00:47

    If you don't mind it being rasterized at a specifc size, you could use the SwingFXUtils.toFXImage static method in javafx.embed.swing:

        TeXFormula tex = new TeXFormula("a + b \\cdot x");
        java.awt.Image awtImage = tex.createBufferedImage(TeXConstants.STYLE_TEXT, 12, java.awt.Color.BLACK, null);
        Image fxImage = SwingFXUtils.toFXImage((BufferedImage) awtImage, null);
        ImageView view = new ImageView(fxImage);
    

    The fxImage instance could also be passed to the Labeled.setGraphic method for use in certain controls (e.g. buttons).

提交回复
热议问题