-2

I am new to java and I would like to convert a buffered image to a regular image object and then display to the screen. I am currently following this method ( JavaFX ImageView via FXML does not work ), but I am having trouble importing this library javafx.embed.swing.SwingFXUtils

into my eclipse project, it claims that there is no such path as javafx.embed which causes an error at the import statement any help or guidance is appreciated thank you

Edit: all other parts of the javaFX library such as buttons and text fields work fine so javaFX is configured properly, It is just with this 1 import I have a problem with

  • Are you able to import other `javafx.` classes? – Basil Bourque Feb 09 '22 at 03:08
  • 1
    Do you understand that JavaFX is not a standard part of Java, and is not built in? – Basil Bourque Feb 09 '22 at 03:14
  • 2
    We need more information to work out what is happening. I suggest doing a quick run through the OpenFX tutorial to make sure your environment is setup correctly: https://openjfx.io/openjfx-docs/ and make sure you have the JavaFX libraries added to your project, or available on the classpath – sorifiend Feb 09 '22 at 03:25
  • @Basil yes all the other subclasses like javafx.application showup – Ranger 4860 Feb 09 '22 at 03:39
  • @sorifend the javafx current configurations work becuase they are able to support things like buttons and textfields the issue is it is unable to find this specific dependency – Ranger 4860 Feb 09 '22 at 03:41
  • 4
    I wonder if it might have to do with `javafx.embed.swing.SwingFXUtils` being in another module, [`javafx.swing`](https://openjfx.io/javadoc/17/javafx.swing/module-summary.html). – Basil Bourque Feb 09 '22 at 05:47
  • 2
    Add these additional details as edits to your Question rather than as Comments. – Basil Bourque Feb 09 '22 at 06:28
  • 1
    See [this info on adding JavaFX modules to your project](https://stackoverflow.com/a/53237667/1155209), but instead of javafx.media, write javafx.swing when referencing the module and javafx-swing when referencing the dependency or jar containing the javafx.swing module. If using maven or gradle you need to have a dependency on javafx-swing. – jewelsea Feb 09 '22 at 11:27
  • 1
    _so javaFX is configured properly_ if so, you wouldn't see any error, would you ;) Repeating (what others already noted): make sure you have the __module__ swingfx in your path. And show the details that's needed to answer: [mcve] including build path, module-info .. – kleopatra Feb 09 '22 at 13:50

1 Answers1

-2

As javaFX is already bundled with JDK 8. I would suggest, try using java 8 instead, if it works, then your previous setup wasn't correct.