Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.File;
import java.net.MalformedURLException;

import javafx.application.Application;
import javafx.scene.image.Image;
import javafx.stage.Stage;

public class Main extends Application {
    @Override
    public void start(Stage primaryStage) {
        try {
            File file = new File("C:/Users/abc/myphoto.jpg");
            String localUrl = file.toURI().toURL().toString();
            // don't load in the background
            Image localImage = new Image(localUrl, false);

            String remoteUrl = "http://java2s.com/style/demo/Firefox.png";
            // load in the background
            Image remoteImage = new Image(remoteUrl, true);

            System.out.println(localUrl);
            System.out.println(remoteUrl);

        } catch (MalformedURLException ex) {
            // error
        }
    }

    public static void main(String[] args) {
        launch(args);
    }
}