Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//implement missing components from this calculator in the java code below for calculator so that the output is exactly what is in the screenshot/image below

//implement missing components from this calculator in the java code below for calculator so that the output is exactly what is in the screenshot/image below the code

import java.awt.*; import java.awt.event.*; import javax.swing.*;

@SuppressWarnings("serial") public class Calculator extends JFrame implements ActionListener { //Declare the objects. private JLabel myTitle; private Font myTitleFont; private JButton FClear; private JPanel myPanel; private JTextField result; public static void main(String[] args) { new Calculator(); }

public Calculator() { setSize(500, 680); setTitle("CSCI-141"); this.setResizable(false);

myTitle = new JLabel("Calculator"); myTitleFont = new Font(Font.MONOSPACED,Font.PLAIN,40); //Create TextFields, buttons, and panels. myPanel = new JPanel(); myPanel.setLayout(new FlowLayout()); myPanel.setPreferredSize(new Dimension(500, 500)); result = new JTextField(20); FClear = new JButton("C");

//Add action listener FClear.addActionListener(this); myPanel.add(myTitle); myPanel.add(result); myPanel.add(FClear); this.getContentPane().add(myPanel); this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }

public void actionPerformed(ActionEvent e) { if(e.getSource() == FClear) { result.setText(""); } //Add missing button actions } }

image text in transcribed

Here's what a sample run should look like: CSCI-141 CSCI-141 CSCI-141 CSCI-141 Calculator Calculator Calculator Calculator 2.4 7.4

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

SQL Server T-SQL Recipes

Authors: David Dye, Jason Brimhall

4th Edition

1484200616, 9781484200612

More Books

Students also viewed these Databases questions

Question

What is the environment we are trying to create?

Answered: 1 week ago