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.
|