I'm going through the book "Quick Start Guide to JavaFX" I'm on Chapter 7 and for some reason my image won't load
Here is my code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chapter7;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
import javafx.scene.image.ImageView;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
/**
*
* @author svetlana
*/
public class Chapter7 extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Image butterfly = new Image("http://pngimg.com/uploads/butterfly/butterfly_PNG1024.png");
ImageView imageView = new ImageView();
imageView.setImage(butterfly);
imageView.setFitWidth(300);
imageView.setPreserveRatio(true);
StackPane root = new StackPane();
root.getChildren().add(imageView);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}
These are the errors that NetBeans provides me with
ant -f /home/svetlana/NetBeansProjects/Chapter7 jfxsa-run
init:
Deleting: /home/svetlana/NetBeansProjects/Chapter7/build/built-jar.properties
deps-jar:
Updating property file: /home/svetlana/NetBeansProjects/Chapter7/build/built-jar.properties
Compiling 1 source file to /home/svetlana/NetBeansProjects/Chapter7/build/classes
compile:
Detected JavaFX Ant API version 1.3
Launching <fx:jar> task from /usr/lib/jvm/java-8-oracle/jre/../lib/ant-javafx.jar
Warning: From JDK7u25 the Codebase manifest attribute should be used to restrict JAR repurposing.
Please set manifest.custom.codebase property to override the current default non-secure value '*'.
Launching <fx:deploy> task from /usr/lib/jvm/java-8-oracle/jre/../lib/ant-javafx.jar
No base JDK. Package will use system JRE.
No base JDK. Package will use system JRE.
jfx-deployment-script:
jfx-deployment:
jar:
Copying 12 files to /home/svetlana/NetBeansProjects/Chapter7/dist/run1372567593
jfx-project-run:
Executing /home/svetlana/NetBeansProjects/Chapter7/dist/run1372567593/Chapter7.jar using platform /usr/lib/jvm/java-8-oracle/jre/bin/java
Deleting directory /home/svetlana/NetBeansProjects/Chapter7/dist/run1372567593
jfxsa-run:
BUILD SUCCESSFUL (total time: 6 seconds)
I'm able to visit the picture if I can go directly from the browser.