Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Declare an instance of DataManager at the FXMainPane class level so that its scope extends throughout the class. Instantiate it in the constructor. To set


  1. Declare an instance of DataManager at the FXMainPane class level so that its scope extends throughout the class. Instantiate it in the constructor.


  1. To set the buttons to respond to mouse-clicks,
    1. create an inner class at the class level (for example, called ButtonHandler) that implements EventHandler. For each button, use button.setOnAction(new ButtonHandler()).
    2. This interface requires the method handle(ActionEvent event) to be implemented. The mouse event is provided to the handle method, and event.getTarget() returns the object that caused the event, allowing a selection to be made.
    3. Implement an if-else-if structure that gets the target button that was selected and executes the appropriate block of code.
      1. If the "Hello", "Howdy" or "Chinese" buttons were selected, call the DataManager instance's methods getHello, getHowdy, or getChinese and call the text field's method setText with the response from the DataManager.
      2. If the "Clear" button was selected, call the text field's method setText(""); to clear out the text field.
      3. If the "Exit" button was selected, call Platform.exit(); and System.exit(0);


  1. Position the components so they are generally centered and spaced apart.
    1. To set margins for each component, call the static method on the containing component, e.g., HBox.setMargin(button1, inset);where inset is an instance of the class Inset.
    2. To center each HBox, use hBox.setAlignment(Pos.CENTER); where Pos is an Enum that will need to be imported.


  1. JUST FOR FUN (optional): create a sixth button that says "Hello" in another language. Add a method to the DataManager class to return the string.


  1. Add the files to GitHub in a directory named CMSC203_Lab2


Compile and run FXDriver. Select each of the buttons to ensure they are working correctly.

Submit the three java files to Blackboard. If any of these instructions is confusing to you, download and study the code in GUI_Template.zip in Week 4.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a breakdown of the instructions incorporating best practices 1 Declare and Instantiate DataMan... 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

Introduction To Programming With Java A Problem Solving Approach

Authors: John Dean

3rd International Edition

1260575241, 9781260575248

More Books

Students also viewed these Programming questions

Question

Provide three user interface design guidelines for GUI programs.

Answered: 1 week ago