I am trying to upload images from my computer folder to a thumbnail wall. I read in a thread from another forum that the ImageView
instance variable "url" does not support system paths. I tried with the solution there, but it throws an exception: java.lang.OutOfMemoryError: Java heap space as it keeps reading the file
.
Another problem is that it continues to warn me about using the javafx.ext -> SwingUtils.toFXImage method.
I also tried to enter the url like this:
"file://localhost//Users/USER/Pictures/Camera/test/1.JPG"
I tried to display multiple images, but it always displays only 3-4 images.
I checked with the error function set from ImageView
, it does not indicate that an error occurred while reading my images.
Are there any alternatives?
The code
function load() { println("RUNTIME {Runtime.getRuntime().maxMemory()}"); System.gc(); Runtime.getRuntime().freeMemory(); //MAC Folder PATH var path: String = "/Users/username/Pictures/camera/test/1.JPG";; var file: File = new File(path); //http://download.oracle.com/docs/cd/E17802_01/javafx/javafx/1.3/docs/api/javafx.ext.swing/javafx.ext.swing.SwingUtils.html //public toFXImage(image: java.awt.image.BufferedImage) : Image //Creates a JavaFX Image from a BufferedImage. img = SwingUtils.toFXImage(ImageIO.read(file)); }
source share