Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-12-2009, 03:22 PM
Member
 
Join Date: Dec 2008
Posts: 27
Rep Power: 0
ajeeb is on a distinguished road
Default JavaFX not able to read images
Hi,
My javafx code is not able to read image and hence not able to display it on runtime. Am using Net Beans IDE. Other nodes (Circle & Text are appearing fine). Any ideas please ?
Code:
Code:
package test2;

import javafx.scene.Group;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.text.Text;
import javafx.stage.Stage;

Stage {
    title: "Group-Nodes-Transformation"
    scene: Scene {
        width: 600
        height: 600
        content: Group {
            content: [
                Circle {
                    centerX: 300
                    centerY: 300
                    radius: 250
                    fill: Color.WHITE
                    stroke: Color.BLACK
                },
                Text {
                    x: 300
                    y: 300
                    content: "Mr. Duke"
                },
                ImageView {
                    image: Image {
                        url: "D:\\TEST\\Documents\\duke.png"
                        width:50
                        height:50
                    }
                }
            ]//content
        }//Group
    }//Scene
}//Stage
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-07-2009, 10:26 AM
Member
 
Join Date: Apr 2009
Posts: 2
Rep Power: 0
sithumm is on a distinguished road
Default Alternate way read images in JavaFx
Hey ajeeb,

I got the same problem. I'll give you a solution as soon as i get one.

Last edited by sithumm; 04-07-2009 at 11:18 AM.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-08-2009, 06:12 PM
Member
 
Join Date: Apr 2009
Posts: 2
Rep Power: 0
sithumm is on a distinguished road
Default JavaFX provides an alternate way!!!!!!!
Hey ajeeb,

I don't know whether you got the answer for this question elsewhere. I joined this forum just yesterday. Although your post is quite old I thought of answering bcoz no one else has answered.
Answer is quite simple. "url" instance varable does not support system paths. So JavaFX provides "fromBuffereImage(java.awt.image.BufferedImage ): Image" method which has a BufferedImage argument and returns a JavaFX Image object.
You have to modify your code as follows:

package test2;

import javafx.scene.Group;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.paint.Color;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.text.Text;
import javafx.stage.Stage;
//Add imports for ImageIO, File, BufferedImage

var img = Image {};

Stage {
title: "Group-Nodes-Transformation"
scene: Scene {
width: 600
height: 600
content: Group {
content: [
Circle {
centerX: 300
centerY: 300
radius: 250
fill: Color.WHITE
stroke: Color.BLACK
},
Text {
x: 300
y: 300
content: "Mr. Duke"
},
ImageView {
image: img.fromBufferedImage(ImageIO.read(new File("D:\\TEST\\Documents\\duke.png")));
}
]//content
}//Group
}//Scene
}//Stage

Last edited by sithumm; 04-08-2009 at 06:15 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-29-2009, 09:41 PM
Member
 
Join Date: Dec 2009
Posts: 1
Rep Power: 0
netsuvi is on a distinguished road
Default
just make a url out of the url like
url: "file:\D:\\TEST\\Documents\\duke.png"

and it will work. At least on windows. On Linux I am still working to get this running.

Cheers
suvi.org
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 02-16-2010, 04:16 PM
PhHein's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Germany
Posts: 466
Rep Power: 1
PhHein is on a distinguished road
Default
Welcome! Please don't hijack other people's threads and find the appropriate subforum for your posts. Introductions - Java Forums
__________________
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaFX Script and JavaFX Mobile levent Java Announcements 1 01-27-2010 05:48 PM
java.io.IOException: Unable to read entire block; 493 bytes read before EOF; expected kushagra New To Java 5 10-17-2008 03:13 PM
Indentation Size Reset While Coding JavaFX JDCAce NetBeans 0 10-06-2008 10:28 PM
images amith AWT / Swing 3 06-27-2008 09:38 PM
Lobo Browser 0.98 - Now With JavaFX Support lobochief Java Announcements 0 03-10-2008 04:00 PM


All times are GMT +2. The time now is 08:57 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org