Question: 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
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 * 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.
Step by Step Solution
There are 3 Steps involved in it
The object ... View full answer
Get step-by-step solutions from verified subject matter experts
