Question: Code Completion 11.105 Combo box with functions Complete this function calculator so that it can compute the functions abs, sqrt, and log10. When the user

Code Completion 11.105 Combo box with functions

Complete this function calculator so that it can compute the functions abs, sqrt, and log10. When the user selects a function name in the combo box, update the output label.

Here is a sample program output:

Code Completion 11.105 Combo box with functions Complete this function calculator so

Complete the following code:

import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; import javax.swing.JComboBox; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class CalcFrame extends JFrame { private JTextField input; private JLabel output; private JComboBox function; public CalcFrame() { function = new JComboBox(); // Your work here input = new JTextField(10); input.setText("10"); output = new JLabel("Select a function"); setLayout(new FlowLayout()); add(function); add(input); add(output); } } 

The following class is used to check your work:

import javax.swing.JFrame; public class CalcFrameViewer { public static void main(String[] s) { CalcFrame frame = new CalcFrame(); frame.setSize(400, 75); frame.setTitle("CalcFrameViewer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } 

CalcFrame Viewer sqrt 10 abs O X 3.1622776601683795

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!