Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I get the following error and am not sure how to remove it. Nothing displays. Have you seen this and how do you address to

I get the following error and am not sure how to remove it. Nothing displays. Have you seen this and how do you address to allow the program to run?

package caesarcipherfx1;

import javafx.application.Application; import javafx.collections.FXCollections; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.ComboBox; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; import javafx.stage.Stage;

public abstract class CaesarCipherFX1 extends Application {

public abstract class CaesarCipherFX extends Application {

} //textfield TextField TF1 = new TextField(); TextField TF2 = new TextField();

//button Button translateButton = new Button("Translate"); Button copyButton = new Button("Copy Up"); Button clearButton = new Button("Clear");

//combo box ComboBox combo_box;

@Override public void start(Stage primaryStage) throws Exception {

// Create a gridpane GridPane gridPane = new GridPane();

gridPane.setHgap(10);

gridPane.setVgap(10);

String choice[] = { "-3", "-2", "-1", "0", "1", "2", "3" };

combo_box = new ComboBox(FXCollections.observableArrayList(choice));

//set the first option to default combo_box.getSelectionModel().selectFirst();

//add components to gridPane gridPane.add(new Label("Key: "), 0, 0);

gridPane.add(combo_box, 1, 0); gridPane.add(new Label("Message: "), 0, 1);

gridPane.add(TF1, 1, 1);

gridPane.add(new Label("Translated Message: "), 0, 2);

gridPane.add(TF2, 1, 2);

gridPane.add(translateButton, 0, 3);

gridPane.add(copyButton, 1, 3); gridPane.add(clearButton, 2, 3);

//set alignment to componenets gridPane.setAlignment(Pos.CENTER);

TF1.setAlignment(Pos.BOTTOM_RIGHT);

TF2.setAlignment(Pos.BOTTOM_RIGHT);

translateButton.setAlignment(Pos.BOTTOM_RIGHT);

copyButton.setAlignment(Pos.BOTTOM_CENTER);

clearButton.setAlignment(Pos.BOTTOM_RIGHT);

TF2.setEditable(false);

//set onAction translateButton.setOnAction(e -> { if (TF1.getText() != null && !TF1.getText().equals("")) { String message = TF1.getText(); int key = Integer.parseInt(combo_box.getValue().toString()); translate(message, key); } });

copyButton.setOnAction(e -> { if (TF2.getText() != null && !TF2.getText().equals("")) { TF1.setText(TF2.getText()); TF2.setText(""); } });

clearButton.setOnAction(e -> { TF1.setText(""); TF2.setText(""); });

//Create a sceen and place it in the stage Scene scene = new Scene(gridPane, 400, 350);

primaryStage.setTitle("CaesarCipher");

primaryStage.setScene(scene);

primaryStage.show();

}

private void translate(String message, int key) { String translatedMessage = ""; for (int i = 0; i < message.length(); i++) {

//for uppercase if (Character.isUpperCase(message.charAt(i))) { char ch = (char) (((int) message.charAt(i) + key - 65) % 26 + 65); if ((int) ch < 65) { ch = (char) (ch + 26); } translatedMessage += "" + ch; } //for lowercase else { char ch = (char) (((int) message.charAt(i) + key - 97) % 26 + 97); if ((int) ch < 97) { ch = (char) (ch + 26); } translatedMessage += "" + ch; }

TF2.setText(translatedMessage);

}

}

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

}

ant -f C:\\Users\\Owner\\Documents\\NetBeansProjects\\CaesarCipherFX1 jfxsa-run init: Deleting: C:\Users\Owner\Documents\NetBeansProjects\CaesarCipherFX1\build\built-jar.properties deps-jar: Updating property file: C:\Users\Owner\Documents\NetBeansProjects\CaesarCipherFX1\build\built-jar.properties Compiling 1 source file to C:\Users\Owner\Documents\NetBeansProjects\CaesarCipherFX1\build\classes Note: C:\Users\Owner\Documents\NetBeansProjects\CaesarCipherFX1\src\caesarcipherfx1\CaesarCipherFX1.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. compile: Detected JavaFX Ant API version 1.3 Launching task from C:\Program Files\Java\jdk1.8.0_111\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_111\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\Owner\Documents\NetBeansProjects\CaesarCipherFX1\dist un327239157 jfx-project-run: Executing C:\Users\Owner\Documents\NetBeansProjects\CaesarCipherFX1\dist un327239157\CaesarCipherFX1.jar using platform C:\Program Files\Java\jdk1.8.0_111\jre/bin/java Exception in Application constructor 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: Unable to construct Application instance: class caesarcipherfx1.CaesarCipherFX1 at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.InstantiationException at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:819) at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326) at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295) at java.security.AccessController.doPrivileged(Native Method) at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(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$148(WinApplication.java:191) ... 1 more Exception running application caesarcipherfx1.CaesarCipherFX1 Java Result: 1 Deleting directory C:\Users\Owner\Documents\NetBeansProjects\CaesarCipherFX1\dist un327239157 jfxsa-run:

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago

Question

10. Discuss the complexities of language policies.

Answered: 1 week ago

Question

1. Understand how verbal and nonverbal communication differ.

Answered: 1 week ago