Question

Please Help, JavaFX assignment. This assignment will focus on the use anonymous inner class handlers to...

Please Help, JavaFX assignment.

This assignment will focus on the use anonymous inner class handlers to implement event handling.

Assignment 12
Assignment 12 Submission


Follow the directions below to submit Assignment 12:

  1. This assignment will be a modification of the Assignment 11 program.
  2. This program should use the controls and layouts from the previous assignment. No controls or layouts should be added or removed for this assignment.
  3. Add event handlers for the three buttons. The event handlers should be implemented as anonymous inner class handlers. An example of anonymous inner class handlers can be found in section 15.5 of the textbook.
  4. The event handler for the encrypt button should call the encryptString() method in the EncryptString class. The input text should be passed to the encryptString() method and the value returned should be displayed in the output TextArea field.
  5. The event handler for the clear button should clear any text in the input TextArea and the output TextArea.
  6. The event handler for the decrypt button should call the decryptString() method in the EncryptString class. The input text should be passed to the decryptString() method and the value returned should be displayed in the output TextArea field.

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.control.*;

import javafx.scene.layout.*;

import javafx.stage.Stage;

import javafx.geometry.*;

public class JavaFX extends Application {

@Override

public void start(Stage primaryStage) throws Exception {

//creates title of primary stage
primaryStage.setTitle("GridPane Experiment");

//creating labels

Button encrypt = new Button("Encrypt");

Button clear = new Button("Clear");

Button decrypt = new Button("Decrypt");

Label inputLabel = new Label("Input Text");

Label outputLabel = new Label("Output Text");

TextArea inputText = new TextArea("Input text here");

TextArea outputText = new TextArea("Output text here");

//Creates a Flow Pane

FlowPane flowpane = new FlowPane();

//Setting the horizontal gap
flowpane.setHgap(5);

flowpane.setPadding(new Insets(1, 10, 10, 10));

flowpane.getChildren().add(encrypt);

flowpane.getChildren().add(clear);

flowpane.getChildren().add(decrypt);

//Setting the Flow alignment

flowpane.setAlignment(Pos.CENTER);

GridPane gridPane = new GridPane();

//Setting the vertical gap between the columns

gridPane.setVgap(5);

//Set the using Insets class

gridPane.setPadding(new Insets(10, 10, 10, 10));

//Arranging all the nodes in the grid


gridPane.add(inputLabel, 0, 0, 1, 1);

gridPane.add(inputText, 0, 1, 1, 1);

gridPane.add(flowpane, 0, 2, 1, 1);

gridPane.add(outputLabel, 0, 3, 1, 1);

gridPane.add(outputText, 0, 4, 1, 1);

//Sets size for the pane

Scene scene = new Scene(gridPane, 500, 450);

primaryStage.setScene(scene);

primaryStage.show();

}

public static void main(String[] args) {

Application.launch(args);

}

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

You haven't provided the EncryptString Class, Any way I have written the instruction in comment where you have to call the encrypt and decrypt method from that class.
You will get the output as per the string returned from the EncryptString class when you call the corresponding method to get the string. Please refer th instructions in bold strings

OUTPUT:

CODE:

package javafx.application;

import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.stage.Stage;
import javafx.geometry.*;

public class JavaFX extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception {
        //creates title of primary stage
        primaryStage.setTitle("GridPane Experiment");
        //creating labels
        Button encrypt = new Button("Encrypt");

        Button clear = new Button("Clear");
        Button decrypt = new Button("Decrypt");
        Label inputLabel = new Label("Input Text");
        Label outputLabel = new Label("Output Text");
        TextArea inputText = new TextArea("Input text here");
        TextArea outputText = new TextArea("Output text here");

        encrypt.setOnMouseClicked( event-> {
            //read text from input text area
            String text = inputText.getText();
            //Call encrypt method from class EncryptClass
            String text2 = encryptString(text);
            //Set encrypted text to output
            outputText.setText(text2);
        });
        decrypt.setOnMouseClicked(event -> {
            //read text from input text area
            String text = inputText.getText();
            //Call encrypt method from class EncryptClass
            String text2 = decryptString(text);
            //Set Decrypted text to output
            outputText.setText(text2);
        });


        clear.setOnMouseClicked(event -> {
            //Clear input and output text Area
            inputText.clear();
            outputText.clear();
        });
        //Creates a Flow Pane
        FlowPane flowpane = new FlowPane();
        //Setting the horizontal gap
        flowpane.setHgap(5);
        flowpane.setPadding(new Insets(1, 10, 10, 10));
        flowpane.getChildren().add(encrypt);
        flowpane.getChildren().add(clear);
        flowpane.getChildren().add(decrypt);
        //Setting the Flow alignment
        flowpane.setAlignment(Pos.CENTER);
        GridPane gridPane = new GridPane();
        //Setting the vertical gap between the columns
        gridPane.setVgap(5);
        //Set the using Insets class
        gridPane.setPadding(new Insets(10, 10, 10, 10));
        //Arranging all the nodes in the grid
        gridPane.add(inputLabel, 0, 0, 1, 1);
        gridPane.add(inputText, 0, 1, 1, 1);
        gridPane.add(flowpane, 0, 2, 1, 1);
        gridPane.add(outputLabel, 0, 3, 1, 1);
        gridPane.add(outputText, 0, 4, 1, 1);
        //Sets size for the pane
        Scene scene = new Scene(gridPane, 500, 450);
        primaryStage.setScene(scene);
        primaryStage.show();

    }
    public String encryptString(String text){
        // You need to add code to call encrypt method from class EncryptString on string text
        // then return that encrypted string
        return "Encrypted " + text;
    }

    public String decryptString(String text){
        // You need to add code to call decrypt method from class EncryptString on string text
        // then return that decrypted string
        return "decrypted " + text;
    }

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

}
Add a comment
Know the answer?
Add Answer to:
Please Help, JavaFX assignment. This assignment will focus on the use anonymous inner class handlers to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming Assignment (JavaFX required). You will modify the SudokuCheckApplication program that is listed below. Start...

    Java Programming Assignment (JavaFX required). You will modify the SudokuCheckApplication program that is listed below. Start with the bolded comment section in the code below. Create a class that will take string input and process it as a multidimensional array You will modify the program to use a multi-dimensional array to check the input text. SudokuCheckApplication.java import javafx.application.*; import javafx.event.*; import javafx.geometry.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.*; public class SudokuCheckApplication extends Application { public void start(Stage primaryStage)...

  • Intro to Java - Assignment JAVA ASSIGNMENT 13 - Object Methods During Event Handling Assignment 13...

    Intro to Java - Assignment JAVA ASSIGNMENT 13 - Object Methods During Event Handling Assignment 13 Assignment 13 Preparation This assignment will focus on the use of object methods during event handling. Assignment 13 Assignment 13 Submission Follow the directions below to submit Assignment 13: This assignment will be a modification of the Assignment 12 program (see EncryptionApplication11.java below). Replace the use of String concatenation operations in the methods with StringBuilder or StringBuffer objects and their methods. EncryptTextMethods.java ====================== package...

  • The JavaFX framework provides more than one way to handle events. For event handlers, we could...

    The JavaFX framework provides more than one way to handle events. For event handlers, we could use inner classes, anonymous inner classes, or the new Java 8 feature of lambda expressions. In this discussion, you will explore these different ways of writing event handles in JavaFX. To prepare for this discussion, you must unzip the attached NetBeans project zip file (U4D1_HandleEvents.zip) and load it into your NetBeans IDE. The project uses an inner class to handle the click event on...

  • Can someone please comment this on what the javafx do and how they are implemented? import...

    Can someone please comment this on what the javafx do and how they are implemented? import javafx.application.Application; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.scene.paint.Paint; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; public class TextPanel extends Application { GridPane grid = null; Text scenetitle = null; Label tDrawLabel = null; Label bsc345Label = null; HBox THBox = null; VBox mVBox = new VBox(2); Stage primaryStage = null; @Override public void start(Stage...

  • For this question you will need to complete the methods to create a JavaFX GUI application...

    For this question you will need to complete the methods to create a JavaFX GUI application that implements two String analysis algorithms. Each algorithm is activated when its associated button is pressed. They both take their input from the text typed by the user in a TextField and they both display their output via a Text component at the bottom of the GUI, which is initialized to “Choose a string methods as indicated in the partially completed class shown after...

  • use this code of converting Km to miles , to create Temperature converter by using java...

    use this code of converting Km to miles , to create Temperature converter by using java FX import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.geometry.Pos; import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.Button; import javafx.event.EventHandler; import javafx.event.ActionEvent; /** * Kilometer Converter application */ public class KiloConverter extends Application { // Fields private TextField kiloTextField; private Label resultLabel; public static void main(String[] args) { // Launch the application. launch(args); } @Override public void start(Stage primaryStage) { //...

  • JavaFX! Just need to fill several lanes of code please!!! CSE205 OOP and Data Structure Quiz #15 Last Name (print) First Name (print) Write a JavaFX GUI application program that simulates a timer. T...

    JavaFX! Just need to fill several lanes of code please!!! CSE205 OOP and Data Structure Quiz #15 Last Name (print) First Name (print) Write a JavaFX GUI application program that simulates a timer. The timer should show "count: the beginning and increase the number by 1 in every one second, and so on. o" at .3 A Timer - × A Timer Count: 0 Count: 1 (B) After 1 second, the GUI Window (A) Initial GUI Window According to the...

  • Examine the following code and complete missing parts: import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets;...

    Examine the following code and complete missing parts: import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class NtoThePowerOfN extends Application{ @Override public void start(Stage primaryStage) throws Exception { TextField inputField; TextField outputField; VBox base = new VBox(10); base.setPadding(new Insets(10)); base.setAlignment(Pos.CENTER); // // A: input components - label and text field // // // B: button - to compute the value // // //...

  • You may adjust the code as you want. Thank you! CODING HERE: import javafx.application.Application; import javafx.event.*;...

    You may adjust the code as you want. Thank you! CODING HERE: import javafx.application.Application; import javafx.event.*; import javafx.scene.*; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.*; import javafx.geometry.*; public class OrderSystem extends Application implements EventHandler<ActionEvent> { // Attributes for GUI private Stage stage; // The entire window, including title bar and borders private Scene scene; // Interior of window private BorderPane layout; // Add four labels private Label itemLabel = new Label("Item Name:"); private Label numberLabel = new Label("Number:"); private Label costLabel...

  • Use Kilometer Converter application code to write Temperature Converter application to convert degrees Fahrenheit into degrees...

    Use Kilometer Converter application code to write Temperature Converter application to convert degrees Fahrenheit into degrees Celsius ((F - 32)*5/9). It needs to be JavaFX 1 import javafx.application. Application; 2 import javafx.stage. Stage; 3 import javafx.scene. Scene; 4 import javafx.scene.layout.HBox; 5 import javafx.scene.layout. VBox; 6 import javafx.geometry.Pos; 7 import javafx.geometry.Insets; 8 import javafx.scene.control.Label; 9 import javafx.scene.control. TextField; 10 import javafx.scene.control.Button; 11 import javafx.event. EventHandler; 12 import javafx.event. ActionEvent; 13 14 ** 15 * Kilometer Converter application 16 17 18 public...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT