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: 0% (2 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...
-
When operated from a 230-V dc supply, a dc series motor operates at 975 r/min with a line current of 90 A. Its armature-circuit resistance is 0.11 and its series-field resistance is 0.08. Due to...
-
List two ways in which monitoring by the Joint Monitoring Unit and the ACCA monitoring unit differ and give reasons to explain these differences.
-
The town of Newport obtained a corporate MasterCard that was given to the town clerk for purchasing fuel for the town hall. The town clerk used the card for personal restaurant, hotel, and gift shop...
-
In the context of bioseparations, what are the latest advancements in chromatographic techniques for purifying biological products, and how do they address issues of throughput, purity, and...
-
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?
-
A data set has n = 20. 20i=1 xi = 8.552, 20i=1yi, = 398.2, 20i=1 x2i, = 5.196. 20i =1 y2i = 9356 and 20i=1 = 216.6. Calculate ^0, ^1, and ^2. What is the fitted value when x = 0.5?
-
In parts of the country where snow is a regular occurrence, local government almost always provides snow removal from public streets but seldom provides snow removal from public sidewalks. Sidewalk...
-
Competing with private- sector salaries is a common problem for some academic depart-ments in universities, particularly in engineering, accounting, other business fields, and biological science. If...
-
Exempting the interest on state-local government bonds from federal income taxation is the lowest-cost way for the federal government to subsidize state-local borrowing costs. Evaluate this statement.
-
Under what conditions would it be possible for an excise tax to have no efficiency cost and, in fact, increase economic efficiency? Give an example or two.
-
In many large cities, the government operates a museum, library, and zoo that are visited by substantial numbers of people who are not residents of the city. They may come from the metropolitan area...
-
What role does iteration play in developing use cases?
-
Nitrogen monoxide reacts with hydrogen as follows: 2NO(g)+ H2(g) N2O(g) + H2O(g) The rate law is [H2]/ t = k[NO]2[H2], where k is 1.10 107 L2/(mol2s) at 826oC. A vessel contains NO and H2 at...
-
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.
-
What is the maximum penalty for using money for other purposes or incorrectly accounting for client monies under Section 211, Offences of the PSA Act 2002: What is the maximum penalty for using money...
-
The price quoted for the transfers from the customer's home in Hazelwood Park to Adelaide Airport doesn't include GST. The price is $125.00. Calculate the GST to determine the selling price. Show...
-
Explain and define the concepts brain neuroplasticity, neurogenesis, and brain lateralization.
Study smarter with the SolutionInn App