Gui controls memory calculator

Assignment Help JAVA Programming
Reference no: EM131578982

GUI Controls Memory Calculator

This is the last homework assignment in this course, and it is meant to show you how a small but complete GUI application is structured. We will make our GUI actually control our memory calculator.

To do this, you will need to create an instance of MemoryCalc in the CalcGUI and write event Handlers to pass information back and forth between the calculator and the GUI. There are many possible ways to achieve this, but the easiest is probably to develop four different event Handlers:

DigitHandler - This event Handler is added to the 0-9 and . (dot) keys. If the equals button was just pressed, this event Handler will overwrite the total shown in the text field with the value of the key (its label) that was just pressed. If the equals button was not just pressed, this event Handler will append the current key's label onto the end of the string shown in the text field.

OperatorHandler - This event Handler is added to the +, -, *, and / keys. It sets the value of a class field to the operator that the user has chosen.

ClearHandler - This event Handler is added to the C key. It calls the calculator's clear method and sets the value of the text field back to 0.0.

EqualsHandler - This event Handler is added to the = key. It reads the current value from the text field, converts it to a double, and calls the appropriate calculator method based on the current operator, passing in the double value. The calculator will compute the answer, and then this event Handler will update the value in the text field to the calculator's current total.

That is all that required for the homework assignment, however I also encourage you to play around with the different types of calculators we have written in this course, perhaps after this course ends. For instance, you could add functionality for geometric operations like sine and cosine. Or you could create a Super Calculator that has different views for scalar, vector, and matrix calculations. Whatever you come up with, I suggest you clean it up and document it. Potential employers always look favorably on being able to review code you have written and ask you questions about it.

Hints:

You can use the ActionEvent's getSource() method to get a reference to the button that was pressed, and you can use Button's getText() method to find out the label of that button.

When the EqualsHandler is converting the text shown in the text field into a double value in order to pass it to the calculator, be careful to handle the case where the text field contains an invalid value, such as 6..72. In this case you should catch the exception, display an error message to the user, and abort the call to the calculator (just restore the current total to the text field).

The user should only be able to enter numbers between when an operator has been selected and when the equals button has been pushed. The DigitHandler should ignore any button presses when the GUI is not in this state.

Reference no: EM131578982

Questions Cloud

Is client stigmatized because of health problems : Is client stigmatized because of health problems? Does the clients' health problem affect his/her social and economic role in society?
What constitutes the necessary quality for the project : Which definition of quality "wins"? What steps can you take to ensure you and the customer agree on what constitutes the necessary quality for the project?
Analyze the manner in which his actions rose : Jack Kevorkian's saying, "dying is not a crime", and analyze the manner in which his actions rose to the level of homicide
Prepare current assets section of yasunari kawabata company : Prepare the current assets section of Yasunari Kawabata Company's December 31, 2017, balance sheet, with appropriate disclosures
Gui controls memory calculator : create an instance of MemoryCalc in the CalcGUI and write event Handlers to pass information back and forth between the calculator and the GUI
Explore the management of human capital in the organization : Briefly explore the management of human capital in the organization. Describe three employment laws and the consequences of non-compliance.
Explain functional alcoholism : Explain Functional Alcoholism and DUI Offense Basics
Describe briefly the health concern you chose : Explain how lifestyle choices and behaviors play a role in this health care concern. Are they significant contributors to this issue?
What is the dividend yield for com-usa : This is expected to continue indefinitely. The company just paid a dividend of $2.00 per share and its stock is selling at $46.00 per share.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java program which defines an unconstrained array

Write a Java program which defines an unconstrained array of user defined length n, that contains n Random numbers and outputs those random numbers that are even numbers

  Create a client class in java to call the sorting class

Create a client class to call the sorting Class. Pass the array of scores to the Sorting class. Sort the array from smallest to largest and printout the sorted array.

  Dijikstra for undirected graph using simple scheme with

dijikstra for undirected graph using simple scheme with array and fibonacci heap and compare the performanceresults

  The waiting state in java programming

Which is the way in which a thread can enter the waiting state in java programming?

  Consider the following conditions

Consider the following conditions: An enqueuer waiting on a full-queue or a dequeuer waiting on an empty queue sleep indefinitely, unless woken up by another thread. A thread must send a signal ONLY when it adds an element to an empty queue or remove..

  Write a program in java to repeat hello world

Write a program in Java to repeat Hello World 10 times. What is JVM (Java Virtual Machine)

  Write java program that calculates total annual compensation

Write a Java application using NetBeans Integrated Development Environment (IDE) that calculates the total annual compensation of a salesperson. Consider the salesperson will earn a fixed salary of .

  Demonstrate your knowledge in a pragmatic way

Summarize everything that we have addressed in the XML Applications course, and provide a mechanism to demonstrate your knowledge in a pragmatic way.

  Write a java program using the java graphics

Your task for this assignment is to write a Java program using the Java Graphics class to create an example of a computer generated image. This is an opportunity for you to explore computer graphics and exercise some individual creativity.

  Program should assign a seat in the first class

If a person enters 1, your program should assign a seat in the first class (rows 1 - 3). If a person enters 2, your program should assign a seat in business class (rows 4 - 7). If a person enters 3, your program should assign a seat in economy class ..

  Create a simple 2d predator-prey simulation.

The goal for this programming project is to create a simple 2D predator-prey simulation. In this simulation the prey are ants and the predators are doodlebugs. These critters live in a world composed of a 20x20 grid of cells.

  Compute area and perimeter of a polygon

Create a project that would let a user compute area and perimeter of a polygon

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd