HW 6 Solution

$30.00

Category:

Description

This homework has one problem which deals with JavaFX GUI and event handling.

 

Eclipse Reminder

 

  1. Create a JavaFX Project

 

  1. Choose: File, New, Other, JavaFX, JavaFXProject.
  2. Supply a project name, g. hw6_FLastname
  3. Choose: Finish

 

  1. Expand the files in the Package Explorer. You will see the following items that were automatically created:

 

  1. An application
  2. A Main class which is where you will write your code.

 

  1. A file named css which is a (empty) style sheet. This is a very powerful and useful technique for styling your GUI; however, we will not use it.
  2. A JavaFX SDK folder and a build file, fxbuild neither of which we will use.

 

  1. Open Main class and write your code there.

 

 

Implement the calculator with the exact GUI layout as shown below:

 

  • The meanings of the buttons for “add”, “subtract”, “multiply”, “divide” are straightforward.

 

  • When button “load” is pressed, the value in “Result” textArea will be loaded as “Operand 1” for subsequent calculations. For example, when “load” is pressed, the value “30.0” will be loaded to the textField of “Operand 1”.

 

  • When button “exp” is pressed, you should raise “Operand 1” to the power of “Operand 2”. For example, if “Operand 1” is 4 and “Operand 2” is 3, the result should be 4*4*4 = 64

 

 

 

Submission

 

Zip the ENTIRE folder hw6_FLastname!! Submit your zip file to Blazeview by the due date. The name of your file should be: hw6_FLastname.zip.

 

Demonstration

 

Demonstrate your application using the exported JAR file during our demo session. A JAR file is a self-runnable file so that this calculator can be launched without the need to open eclipse every time. You can find the instruction on how to export such JAR file from your project at the end of this document.

 

You must demonstrate your application during our demo session to the instructor in person to receive credit. Otherwise, you will get zero for this homework.

 

 

Additional Requirements:

 

  • No late submission will be accepted.

 

  • Please exactly follow the naming rules described above. You will be deducted 10 points for incorrect naming.
  • Write comments at the beginning of your Java source file(s) to indicate your name, student ID,

“CS 1302-A Homework 6”, and the due date.

 

  • Make sure that your programs are well-documented, readable, and user friendly. Make sure you document your programs by adding comments to your statements/blocks so that I can understand your code. You will get 0 to 10 points based on the helpfulness of your comments. You will be deducted 10 points for no comments.

 

  • It is your responsibility to make sure your programs can compile and run correctly. Please be aware that programs that do not compile may receive ZERO

 

  • When grades are returned to you via BlazeView, you have 7 days to meet with the instructor to discuss on grade changes. After 7 days, the grades are written in stone and can’t be changed after that point.

After you ensure that your calculator runs well in eclipse, let’s proceed to make it a self-runnable file (Jar file) so that this calculator can be launched without the need to open eclipse every time.

 

Instructions on exporting an executable JAR file from your Java project

 

Step 1: Exporting from Eclipse

 

Right click your project and click “Refresh”. Alternatively you can right click and hit F5 on your keyboard.

This is to ensure all your code is up to date and won’t conflict when trying to export.

 

 

 

 

Step 2: Right click your project and click “Export”.

Step 3: Expand the “Java” folder and double click the “Runnable JAR file” option.

 

 

 

 

 

 

 

 

Step 4: Configure the specifications of the JAR file.

 

  • The first thing you should do is select the main class (class with the main method) you want to run from the drop down menu under “Launch configuration”.

 

  • Select the “Export destination” via the “Browse…” button or by manually typing the location.

 

  • Ensure the “Extract required libraries into generated JAR” radio button is selected. Do not worry about the rest of the menu. Click “Finish” when you are satisfied with your selections.

Step 5: Find and double-click the JAR file in your destination folder.

 

Have fun with your little calculator!


error: Content is protected !!