Question: U3A1 - JavaFX I am working this assignment. In this assessment, you will design and code your first JavaFX application that defines you to the

U3A1 - JavaFX I am working this assignment. In this assessment, you will design and code your first JavaFX application that defines you to the world. The application displays your name and your favorite food in a font of your choice. In addition, the JavaFX application displays a picture of you and a picture of your favorite sport. If you could use Mark as the name, golf as the sport, pizza as the food and a male avatar picture as the selfie that would be most helpful. The requirements of this application are as follows.

The application is to use the JavaFX framework to:

The application should have the title About Me by JavaFX

Divide the display into four quadrants

In the upper left quadrant, display your name in the font of your choosing

In the upper right quadrant, display a picture of yourself

In the lower left quadrant, display a picture of your favorite sport

In the lower right quadrant, display the name of your favorite food in the font of your choosing

It should look like this -

U3A1 - JavaFX I am working this assignment. In this assessment, you

My build says that it is successful, but no images or boxes are appearing on my screen.

The code I have is this-

package u3a1_aboutmebyjavafx; /** * * @author Andrea */ import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.text.Text; import javafx.scene.text.Font; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.stage.Stage; import java.io.FileNotFoundException; import javafx.geometry.Pos; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox;

public class U3A1_AboutMebyJavaFX extends Application {

@Override public void start(Stage stage) throws FileNotFoundException {

Text text = new Text(); Text text2 = new Text();

Image image = new Image("C:\\Users\\Andrea\\Documents\\NetBeansProjects\\U3A1_AboutMebyJavaFX\\src\\Images\\FacePic.jpg"); Image image2 = new Image("C:\\Users\\Andrea\\Documents\\NetBeansProjects\\U3A1_AboutMebyJavaFX\\src\\Images\\WoWScrnShot_052218_155653.jpg");

ImageView imageView1 = new ImageView(image); ImageView imageView2 = new ImageView(image2); imageView1.setFitHeight(100); imageView1.setFitWidth(100); imageView2.setFitHeight(100); imageView2.setFitWidth(150);

text.setText("Andrea"); text.setFont(new Font(20)); text2.setText("Lettuce Wraps"); text2.setFont(new Font(20));

HBox row1 = new HBox(text, imageView1); row1.setSpacing(80); row1.setAlignment(Pos.CENTER); HBox row2 = new HBox(imageView2, text2); row2.setAlignment(Pos.CENTER); row2.setSpacing(80); VBox vBox = new VBox(row1, row2); vBox.setAlignment(Pos.CENTER);

Scene scene = new Scene(vBox, 400, 300); stage.setTitle("About me by Andrea"); stage.setScene(scene); stage.show();

}

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

}

}

And the results I am getting are this -

ant -f C:\\Users\\Andrea\\Documents\\NetBeansProjects\\U3A1_AboutMebyJavaFX jfxsa-run

init:

Deleting: C:\Users\Andrea\Documents\NetBeansProjects\U3A1_AboutMebyJavaFX\build\built-jar.properties

deps-jar:

Updating property file: C:\Users\Andrea\Documents\NetBeansProjects\U3A1_AboutMebyJavaFX\build\built-jar.properties

Compiling 1 source file to C:\Users\Andrea\Documents\NetBeansProjects\U3A1_AboutMebyJavaFX\build\classes

compile:

Detected JavaFX Ant API version 1.3

Launching task from C:\Program Files\Java\jdk1.8.0_151\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 task from C:\Program Files\Java\jdk1.8.0_151\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 C:\Users\Andrea\Documents\NetBeansProjects\U3A1_AboutMebyJavaFX\dist un2058413693

jfx-project-run:

Executing C:\Users\Andrea\Documents\NetBeansProjects\U3A1_AboutMebyJavaFX\dist un2058413693\U3A1_AboutMebyJavaFX.jar using platform C:\Program Files\Java\jdk1.8.0_151\jre/bin/java

Exception in Application start method

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)

at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)

Caused by: java.lang.RuntimeException: Exception in Application start method

at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)

at java.lang.Thread.run(Thread.java:748)

Caused by: java.lang.IllegalArgumentException: Invalid URL: unknown protocol: c

at javafx.scene.image.Image.validateUrl(Image.java:1121)

at javafx.scene.image.Image.(Image.java:620)

at u3a1_aboutmebyjavafx.U3A1_AboutMebyJavaFX.start(U3A1_AboutMebyJavaFX.java:50)

at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)

at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)

at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)

at java.security.AccessController.doPrivileged(Native Method)

at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)

at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)

at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)

... 1 more

Caused by: java.net.MalformedURLException: unknown protocol: c

at java.net.URL.(URL.java:600)

at java.net.URL.(URL.java:490)

at java.net.URL.(URL.java:439)

at javafx.scene.image.Image.validateUrl(Image.java:1115)

... 11 more

Exception running application u3a1_aboutmebyjavafx.U3A1_AboutMebyJavaFX

Java Result: 1

Deleting directory C:\Users\Andrea\Documents\NetBeansProjects\U3A1_AboutMebyJavaFX\dist un2058413693

jfxsa-run:

BUILD SUCCESSFUL (total time: 3 seconds)

About me By JAVAfx Enter Your Name Here Enter Your food name here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!