Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions

Question

=+2 How does the preparation and support for each type of IE vary?

Answered: 1 week ago

Question

=+What is the extent of the use of each type of IE?

Answered: 1 week ago