Question
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
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started