3 Replies Latest reply: Oct 20, 2011 9:19 AM by 895137 RSS

    Load image from System Path

    895137
      I am trying to load my computer folder images into a wall of thumnails. I read from the link below that ImageView "url" instance varable does not support system paths. I tried with the solution there, but it will cause an java.lang.OutOfMemoryError: Java heap space as it keeps reading the file.

      another problem is it keeps giving me warning of using package javafx.ext --->SwingUtils.toFXImage method.

      Is there any other alternatives?


      Link
      http://www.java-forums.org/netbeans/15845-javafx-not-able-read-images.html

      Codes
      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));
      }
        • 1. Re: Load image from System Path
          895137
          I have also tried to input the URL to be as below


          url: "file://localhost//Users/user/Pictures/Camera/test/1.JPG"


          i tried display 20 times of the image, it only display a randomly 3 or 4 image only when i run my app. THe images will displayed to be empty boxes that create to store them

          i check with the error function given from ImageView, it does not indicate any of my images encountered an error.

          really need help on this. have been trying for days. :(
          • 2. Re: Load image from System Path
            MiPa
            You are using the outdated 1.x version of JavaFX. You should either switch to 2.0 or post your question in the other 1.x Forum.
            • 3. Re: Load image from System Path
              895137
              MiPa wrote:
              You are using the outdated 1.x version of JavaFX. You should either switch to 2.0 or post your question in the other 1.x Forum.
              i know i am using outdated version but my project is worked on 1.3 , it will spent time for me to convert it to 2.0.

              Anyway, my question is post on the JavaFX 1.x and JavaFX Script, i did not post it on 2.0 :)