In the FactorialButton program in Figures 17.8a and 17.8b, what component fires the event that the listener
Question:
In the FactorialButton program in Figures 17.8a and 17.8b, what component fires the event that the listener handles?
Figures 17.8a:
Figures 17.8b:
Transcribed Image Text:
/********************************** * FactorialButton.java * Dean & Dean * * When user clicks button or presses Enter with cursor in input * text box, entered number's factorial displays in output text box. ******************************************************************/ import javax.swing. *; import java.awt. *; import java.awt.event. *; public class Factorial Button extends JFrame { private static final int WIDTH = 300; private static final int HEIGHT = 100; private JTextField xBox; // holds user entry private JTextField xfBox; // holds generated factorial //************************** public Factorial Button() ( createContents(); setVisible(true); setTitle("Factorial Calculator"); setSize (WIDTH, HEIGHT); set Layout (new FlowLayout()); set DefaultCloseOperation (EXIT_ON_CLOSE) ; } // end FactorialButton constructor //************ ***************************** ******* private void createContents() ( ******* xBox= new JTextField(2); xfBox= new JTextField(10); xfBox.setEditable(false); JLabel xLabel = new JLabel("x:"); JLabel xfLabel = new JLabel("x! :"); JButton btn = new JButton("Factorial"); Listener listener = new Listener(); add (x Label); add(xBox); add(xfLabel); add (xfBox); add (btn); xBox. addActionListener(listener); btn.addActionListener(listener); } // end create Contents ********************* ************ Here, we register the same listener with two different components.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 33% (3 reviews)
Its ambi...View the full answer
Answered By
Joseph Ogoma
I have been working as a tutor for the last five years. I always help students to learn and understand concepts that appears challenging to them. I am always available 24/7 and I am a flexible person with the ability to handle a wide range of subjects.
5.00+
1+ Reviews
10+ Question Solved
Related Book For
Introduction To Programming With Java A Problem Solving Approach
ISBN: 9781260575248
3rd International Edition
Authors: John Dean
Question Posted:
Students also viewed these Computer science questions
-
Carol Harris, Ph.D, CPA, is a single taxpayer and she lives at 674 Yankee Street, Durham, NC 27409. Her Social Security number is 793-52-4335. Carol is an Associate Professor of Accounting at a local...
-
Its appropriate to use an anonymous inner class if you are going to use the class only once. In the Factorial program in Figures 17.8a and 17.8b, we use the listener object twice, so that listener...
-
In the createContents method of the FactorialButton program in Figure 17.8a, what type of object calls the add methods? Figure 17.8a: /********************************** * Factorial Button.java *...
-
Ms. Acosta received a job as a teacher with a starting salary of $3 According to her contract, she will receive a 1.5% increase in her salary every year. How much will Ms. Acosta earn in 7 years.
-
Consider the employee database of Figure. Give expressions in QBE, and Datalog for each of the following queries: a. Find the names of all employees who work for First Bank Corporation. b. Find the...
-
Lenovo uses the ZX- 81 chip in some of its laptop computers. The prices for the chip during the past 12 months were as follows: a) Use a 2- month moving average on all the data and plot the averages...
-
2. Prepare the adjusting entry on December 31, 2016. 468 CHAPTER 13 p R O B L E M S P 13-1
-
Walker Company has 15,000 shares of common stock outstanding during all of 2007. It also has two convertible securities outstanding at the end of 2007. These are: 1. Convertible preferred stock:...
-
A company has the following information. What is the cash conversion cycle? Days payable outstanding 24 days Days inventory outstanding 43 days Days sales outstanding 26 days Days cash outstanding 15...
-
What package contains the JOptionPane class?
-
If you want to implement an event handler with an anonymous inner class, what argument do you give to the addActionListener method to register the listener?
-
In Exercises 7982, use a graphing utility and the change-of base property to graph each function. y = log 15 x
-
Listed below are pulse rates (beats per minute) from samples of adult males and females. Does there appear to be a difference? Find the coefficient of variation for each of the two samples; then...
-
When the price of an item goes down, people buy more of it because at a lower price Options: -some new people may be willing to enter the market. -the item is more valuable. -the marginal cost is...
-
2. Find the sum of the following sequences (3 points) a) 1, 2, 3, 4, 5, 150 ... b) 1, 3, 5, 7, 9, ..., 99 c) -4, 1, 6, 11, 16, 21, . 201 ...
-
Solving for Rates What annual rate of return is implied on a $2,600 loan taken next year when $6,300 must be repaid in year 12?
-
Significant Values. In Exercises 9-12, use the range rule of thumb to identify (a) the values that are significantly low, (b) the values that are significantly high, and (c) the values that are...
-
Find the indicated derivatives in problem. dx 4 53
-
Which of the following is FALSE regarding the purchasing power parity (PPP). a. The PPP is a manifestation of the law of one price b. The PPP says that a country with a higher expected inflation can...
-
A well produces 6000 standard cubic feet (scf) of gas for every barrel (bbl) of hydrocarbon liquid. 1. Assuming a heating value of 1000 BTU/scf for gas and six million BTU/bbl for hydrocarbon liquid,...
-
Suppose the taxpayer can time when he is to receive $ 100,000 of income that is fully taxable. Current interest rates are 10% on fully taxable securities and the taxpayer faces a current tax rate of...
-
Compare gray and malleable cast irons with respect to (a) Composition and heat treatment, (b) Microstructure, and (c) Mechanical characteristics.
-
. Emerson Cammack wishes to purchase an annuity contract that will pay him $7,000 a year for the rest of his life. The Philo Life Insurance Company figures that his life expectancy is 20 years, based...
-
Integrity Inc. can sell 20-year, $1,000 par value bonds paying semi-annual interests with a 10% coupon. The bonds can be sold for $1,050 each; flotation cost of $50 per bond will be incurred in this...
-
Duncan Inc. issued 500, $1,200, 8%, 25 year bonds on January 1, 2020, at 102. Interest is payable on January 1. Duncan uses straight-line amortization for bond discounts or premiums. INSTRUCTIONS:...
Study smarter with the SolutionInn App