Write a Java application that creates a GUI with three textboxes and two buttons. The user...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java application that creates a GUI with three textboxes and two buttons. The user enters two numbers in the first two textboxes. If the user clicks the first button, the sum of two numbers are displayed in the third textbox. If the user clicks the second button, the product of two numbers are displayed in the third textbox. Important notes: You do not use any IDE such as NetBeans to create the GUI. • You start from scratch and build the entire interface as a single java file. For example, Test.java. You cannot use any code from outside resources. You must use anonymous inner classes for event handling. Please see the example below to get you started. • • import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Test ( JFrame frame; JButton button; JTextField text; public Test() { frame new JFrame("Inner Class in Action"); button = new JButton("Say Hello"); text= new JTextField(15); Container c= frame.getContentPane(); c.setLayout (new FlowLayout()); c.add(text); } c.add(button); frame.pack(); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }); } public static void main(String args[]) { Test obj= new Test(); button.addActionListener(new ActionListener() { public void action Performed (ActionEvent e) { text.setText("Hello CS Students"); Inner Class in Action Hello CS Students Inner Class in Action Say Hello Say Hello Write a Java application that creates a GUI with three textboxes and two buttons. The user enters two numbers in the first two textboxes. If the user clicks the first button, the sum of two numbers are displayed in the third textbox. If the user clicks the second button, the product of two numbers are displayed in the third textbox. Important notes: You do not use any IDE such as NetBeans to create the GUI. • You start from scratch and build the entire interface as a single java file. For example, Test.java. You cannot use any code from outside resources. You must use anonymous inner classes for event handling. Please see the example below to get you started. • • import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Test ( JFrame frame; JButton button; JTextField text; public Test() { frame new JFrame("Inner Class in Action"); button = new JButton("Say Hello"); text= new JTextField(15); Container c= frame.getContentPane(); c.setLayout (new FlowLayout()); c.add(text); } c.add(button); frame.pack(); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }); } public static void main(String args[]) { Test obj= new Test(); button.addActionListener(new ActionListener() { public void action Performed (ActionEvent e) { text.setText("Hello CS Students"); Inner Class in Action Hello CS Students Inner Class in Action Say Hello Say Hello
Expert Answer:
Answer rating: 100% (QA)
SOLUTION Program import javaawt import javaawtevent import javaxswing class Calculator ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
For the following exercises, you do not use the TAL Distributors database. 1. The DBA asks for your help in planning the data archive for the following TAL Distributors database: Rep (RepNum,...
-
For the following exercises, you do not use the Solmaris Condominium database. 1. The DBA asks for your help in planning the data archive for the following Solmaris Condominium database: Location...
-
Write a Java application that prompts the user for an int and a double and then uses Math class methods to display each of the following: a. The square root of the int b. A random number between 0...
-
Draw isometric projection of the following figure 10 40 50 $30 Pg. 3 : 20
-
From an employee's perspective, what are the disadvantages of using a pay-for-performance plan?
-
Financial statement data for years ending December 31 for Holland Company follows: a. Determine the inventory turnover for 2016 and 2015. b. Determine the number of days' sales in inventory for 2016...
-
The Buffalo Insurance Agency received the following notes during 2010: Requirements 1. Identifying each note by number, compute interest using a 360-day year, and determine the due date and maturity...
-
Companies are using the power of computing to develop continuous monitoring approaches to identify control problems early and to take corrective action on a timely basis. a. Explain how the concept...
-
Reece Enterprises machines heavy-duty brake rotors that are used on commercial airliners. The company's management developed the following standard costs: Standard direct labor hours per rotor...
-
You are the owner of a small business that manages the program, food, and merchandise sales at the Excel Center, where the local professional basketball team plays. In addition to basketball games,...
-
In the context of the text, what should the future look like? What does Yanis Varoufakis's utopia look like? How does he suggest we achieve this? What happens if we fail? View keyboard shortcuts...
-
6 points Save Answer Write a program in C++ that reads the height and the width from the user, then the program calculates the area and perimeter of a rectangle and printing it. area= height * width...
-
(i) Prove that if we use the addition formula, the combined velocity never exceeds the speed of light. Hint: compute cu and show c-u > 0 with the help of c> v and c> u'. (ii) Show that if we obtain u...
-
Find the points of intersection of the graphs of the equations. r = 7(1 + sin(0)) r = 7(1-sin(0)) r 0,0 0 < 2 smaller 0 value larger 0 value KIN (r, 0) = 10 -10 (r, 0) = (0, 0) (r, 0) 5 -0
-
Bramble Widget Company has the following production data for March. table [ [ Month , table [ [ Beg . Work in ] , [ Process Inventory ] ] , table [ [ Units ] , [ Transferred Out ] ] , table [ [ End ....
-
Here is a data set: 331 358 317 397 361 349 362 366 343 353 374 405 405 347 374 370 379 358 381 312 390 342 370 348 354 343 344 312 The goal is to construct a grouped frequency distribution table...
-
3) a) Find the size of the problem that can be solved in 1 hour on a computer that takes 10- sec/op using algorithms with time complexity: log2 n, 10n, 2n, 20 nlog n, 2n and n! b) Redo the problem if...
-
In Exercises 516, find the focus and directrix of the parabola with the given equation. Then graph the parabola. y 2 = 4x
-
A file channel ____________. A. Can be read from B. Can be written to C. Is seekable D. All of the above are true.
-
The Java keyword that creates inheritance is ____________. a. static b. enlarge c. inherits d. extends
-
Which of the following is not necessary to do before you can run a Java program? a. Coding b. Compiling c. Debugging d. Saving
-
The financial management process is important for auditors because of its role in helping to form expectations about financial statement results. To illustrate this concept, explain how an...
-
Consider Manny Corp., our military outfitting operation from Chapter 10. Its financial data is reprinted here for convenience. a. If you were the auditor assigned to perform substantive analytical...
-
Following are some routine procedures for the audit of payroll (discussed in the Appendix). For each procedure, (1) state whether it is a test of controls or a substantive test, (2) state which...
Study smarter with the SolutionInn App