Concept explainers
Design and code a Swing GUI calculator. You can use Display 17.19 as a starting point, but your calculator will be more sophisticated. Your calculator will have two text fields that the user cannot change: One labeled "Result" will contain the result of performing the operation, and the other labeled "Operand" will be for the user to enter a number to be added, subtracted, and so forth from the result. The user enters the number for the "Operand" text field by clicking buttons labeled with the digits o through 9 and a decimal point, just as in a real calculator. Allow the operations of addition, subtraction, multiplication, and division. Use a GridLayout manager to produce a button pad that looks similar to the keyboard on a real calculator.
When the user clicks a button for an operation, the following occurs: the operation is performed, the "Result" text field is updated, and the "Operand" text field is cleared. Include a button labeled "Reset" that resets the "Result" to 0.0. Also include a button labeled "Clear" that resets the "Operand" text field so it is blank.
number in the "Operand" text field. Because values of type double are, in effect, approximate values, it makes no sense to test for equality with 0.0. Consider an operand to be "equal to zero" if it is in the range
Want to see the full answer?
Check out a sample textbook solutionChapter 17 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Mechanics of Materials (10th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
- Extra 7-2 Add a stopwatch to the Clock application In this exercise, you’ll add a stopwatch feature to a digital clock application. The stopwatch will display elapsed minutes, seconds, and milliseconds. 1. Open the application in this folder: exercises_extra\ch07\clock_stopwatch\ 2. In the JavaScript file, note the $(), displayCurrentTime(), padSingleDigit(), and DOMContentLoaded event handler functions from the Clock application. In addition, note the global variables and starting code for the tickStopwatch(), startStopwatch(), stopStopwatch(), and resetStopwatch() functions. 3. In the tickStopwatch() function, add code that adds 10 milliseconds to the elapsedMilliseconds variable and then adjusts the elapsedMinutes and elapsedSeconds variables accordingly. Then, add code that displays the result in the appropriate span tags in the page. 4. In the startStopwatch() function, add code that starts the stopwatch. Be sure to cancel the default action of the link too. 5. In the…arrow_forwardCreate an app that enables the user to play the game of 15. The game has a 4-by-4 board with a total of 16 slots. One slot is empty; the others are occupied by 15 square tiles numbered 1 through 15. The user can move any tile next to the currently empty slot into that slot by clicking that tile. Your app should create the board with the tiles in random order. The goal is to arrange the tiles into sequential order, row by row—that is, 1–4 in the first row, 5–8 in the second row, 9–12 in the third row and 13–15 in the fourth row.arrow_forwardUse Java Programming Language Write a GUI to calculate the number of servings that a circular pizza of a certain diameter will make. The GUI will have the following appearance: It must include the following features: The frame title must say 'Pizza Servings Calculator'. A grid layout will be used for the GUI. The JLabel title of the GUI will say 'Pizza Servings Calculator' and be in red and will be placed in grid slot 1. A JLabel of 'Enter the size of the pizza in inches: ' will be placed in grid slot 2 followed by a JTextField where the pizza size will be entered and have a width of 4. A JButton will be placed in grid slot 3 and will contain 'Calculate Servings'. A JLabel, initially blank, will be placed in grid slot 4. To execute the GUI, enter a pizza size in the JTextField and click the Calculate Servings button. The Calculate Servings button handler will then execute and calculate the number of servings and display it as shown in the following image: The number of…arrow_forward
- In Java FX or Javaarrow_forwardin Javaarrow_forwardJava Question - Create a GUI-based Java application that uses three JLabel, threeJTextFields, and one JButton control to build a GUI “form”, as shown in the attached picture. Set the background color of the form to “pink”. Makesure the output looks similar to the picture. [Note: Be sure to use input and output dialog boxes]. Thank you.arrow_forward
- .arrow_forwardVB create this program on visual basics or any other programming GUI langauge Create one object – Person, and code it. Create the menus shown in the demo program. The interface is a bit different from what you have done to this point. Play with the program to see how it works. The hungarian notation for a date control is dte. Commands The key commands of this program are: Add a Person Remove a Person Display next person Display previous person Display first person Display last person. Create the programming to make these components work. Refer to the power point notes for examples of how the code needs to be set up. Protecting Data against Accidental change Change the display to allow the user to enter data into text boxes, but protect the data from being accidentally changed by setting the ReadOnly property of the text boxes appropriately. This should be a sub. Call it as you need it. The Date has no ReadOnly property, use the Enabled property instead for this control. Use the enabled…arrow_forwardPerfectPaint, a program for creation and manipulation of images. So far, she has created an image with a red circle on a blue background. At 4:30 pm, she decides that she would like to use a different shape instead, and so needs to remove the circle. She plans to select the circle and then use the 'Cut' command, and she knows how to do this. At 4:32 pm, she selects the circle by clicking on it, and then selects 'Cut from the Edit menu, to cut away the circle. She looks at the resulting image and is satisfied to see that the circle has indeed gone. Indicate whether the statements below in connection with the instance described above are True or False. PerfectPaint ، برنامج لإنشاء ومعالجة الصور. حتى الآن ، أنشأت صورة بدائرة حمراء على خلفية زرقاء. في الساعة 4:30 مساءً ، قررت أنها ترغب في استخدام شكل مختلف بدلا من ذلك ، لذا تحتاج إلى إزالة الدائرة. تخطط لتحدید الدائرة ثم تستخدم أمر "قص" ، وهي تعرف كيفية القيام بذلك. في الساعة 4:32 مساءً ، اختارت الدائرة بالنقر فوقها ، ثم حددت "قص" من قائمة…arrow_forward
- For this task, you need to develop a JavaFX application in NetBeans that implements a LinkedHashMap class. The Java application should consist of a graphical user interface that can be used to add elements to the LinkedHashMap. There should be two TextFields to take in the element name and number. Then there should be four buttons to do four tasks, namely: add, change, remove and show all elements in the LinkedHashMap. Your buttons should have Action methods and should make use of methods in the LinkedHashMap class.When the Add button is clicked, the element name and value should be added to the LinkedHashMap. Make use of the LinkedHashMap methods to add the elements. When the user fills in the element name and number and the Add button is clicked, a message should be displayed in an alert dialog box to the user to inform them of this If no element is specified at the time the Add button is clicked, an error message should be displayed to inform the user to enter the elementarrow_forwardSee the picture attached, and create a random number game to make a guess if the upcoming random number will be higher / lower than the current one. To complete the implementation for Java GUI based desktop app, include following functionalities: 2.1 Provide a start/play button on start window. This will allow the users to start their game 2.2 Random numbers counter (Range 0 to 99) and high / low buttons to stop the counter 2.3 Keep generating random numbers until the user fails 2.4 Replace the numbers counter with win/failure label with a button either to start again or to close the game 2.5 Apply multi-threading concept to complete your requirements Please make GUI based desktop app Course: Javaarrow_forward3. Write a GUI application with a single button. Initially the button is labelled "0". When it is first clicked the label becomes "1". When it is clicked a second time it becomes "2", and each time it is clicked it cycles between "0", "1" and "2".arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage