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
-
Data for the unadjusted trial balance of Mexican Riviera Tanning Salon at March 31, 2012, follow. .:. Adjusting data for March 2012 are: a. Accrued service revenue, $2,600. b. Supplies used in...
-
Exel Division is part of the Super Group. It produces a basic fabric which is then converted in other division within the group. The fabric is also produced in other divisions within the Super Group...
-
Procedures to Obtain an Understanding and Audit Planning. On 12 March 1997, Lars Bildman, Chief Executive of Astra USA, Inc., was arrested by US federal officers and charged with 35 counts, including...
-
Two identical, uniform beams weighing 260 N each are connected at one end by a frictionless hinge. A light horizontal crossbar attached at the mid points of the beams maintains an angle of 53.0°...
-
Umma Ltd. A public company quoted on the Nairobi Stock Exchange, owns 80% of Ugeni Ltd. A public company which is situated in a foreign country, Timoa. The currency of this country is Trim(TR). Umma...
-
14 Find an equation for the line which passes through the origin and is perpendicular to 2x 3y 2
-
We suggested a difference between strategic decisions that set the principles for logistics, and those concerned with the practicalities of implementation. Do you think that this is a real...
-
It is often more difficult to implement a logistics strategy than to design one. This is why most logistics plans fail in the practice rather than the theory. Do you think that this is necessarily...
-
Supply chains are not usually designed from scratch, but evolve over time. What problems does this create? Can you suggest a better approach?
-
Can you find any examples of good logistics strategies that have given poor results because of poor implementation? What could have been done better?
-
Which areas of the world do you think will have the fastest economic development over the next twenty years? How will this affect location decisions?
-
2 Rewrite using only positive exponents x 7 5 Make sure you preview your answer using the button and make sure the computer interprets your entry corrrectly Use parentheses for grouping if needed...
-
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
-
Determine whether Graph \(Q_{1}\) is a spanning tree of Graph \(Q\). If not, explain how you know. m n
-
List three unused (solid) edges from Graph \(O\) that cannot be used to complete the spanning tree. A student has been asked to construct a spanning tree for Graph \(O\), as shown in the figure. The...
-
Determine whether Graph \(Q_{3}\) is a spanning tree of Graph \(Q\). If not, explain how you know. m n
Study smarter with the SolutionInn App