Question: Complete the tabbed panel created in class. Build the division and multiplication sections. Use the add and subtract panels as templates. Include image icons for

Complete the tabbed panel created in class. Build the division and multiplication sections. Use the add and subtract panels as templates. Include image icons for the tabs.
Here is the following code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tabbedcalculator;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.*;
import javax.swing.*;
/**
*
* @author aesparza
*/
public class TabbedGUI extends JFrame implements ActionListener{
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT);
JPanel addP = new JPanel();
JPanel subP = new JPanel();
JPanel mulP = new JPanel();
JPanel divP = new JPanel();
//Add the inputted numbers
JTextField num1= new JTextField();
JTextField num2= new JTextField();
JTextField ra = new JTextField();
JLabel number1= new JLabel("Number 1");
JLabel number2= new JLabel("Number 2");
JLabel resulta = new JLabel("result");
//Subtract the inputted numbers
JTextField num3= new JTextField();
JTextField num4= new JTextField();
JTextField rs = new JTextField();
JLabel number1s = new JLabel("Number 1");
JLabel number2s = new JLabel("Number 2");
JLabel results = new JLabel("result");
//Multiply the inputted numbers
JTextField num5= new JTextField();
JTextField num6= new JTextField();
JTextField rm = new JTextField();
JLabel number1m = new JLabel("Number 1");
JLabel number2m = new JLabel("Number 2");
JLabel resultm = new JLabel("result");
//Divide the inputted numbers
JTextField num7= new JTextField();
JTextField num8= new JTextField();
JTextField rd = new JTextField();
JLabel number1d = new JLabel("Number 1");
JLabel number2d = new JLabel("Number 2");
JLabel resultd = new JLabel("result");
JButton add = new JButton("add");
JButton subtract = new JButton("subtract");
JButton multiply = new JButton("multiply");
JButton divide = new JButton("divide");
public TabbedGUI(){
//ActionListener
add.addActionListener(this);
subtract.addActionListener(this);
multiply.addActionListener(this);
divide.addActionListener(this);
//Addition SubPanel layout
addP.setLayout(new GridLayout(4,2));
addP.add(number1);
addP.add(num1);
addP.add(number2);
addP.add(num2);
addP.add(resulta);
addP.add(ra);
addP.add(add);
ImageIcon plus = new ImageIcon("images/plus.png");
tabbedPane.addTab("Add", plus, addP, "Click to add numbers");
tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
//Subtraction SubPanel layout
subP.setLayout(new GridLayout(4,2));
subP.add(number1s);
subP.add(num3);
subP.add(number2s);
subP.add(num4);
subP.add(results);
subP.add(rs);
subP.add(subtract);
ImageIcon minus = new ImageIcon("images/subtract.png");
tabbedPane.addTab("Subtract", minus, subP, "Click to subtract numbers");
tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
//Add to Frame
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.getContentPane().add(tabbedPane);
this.setPreferredSize(new Dimension(500,500));
this.setVisible(true);
this.pack();
}
// Action Listener
@Override
public void actionPerformed(ActionEvent e){
if(e.getSource().equals(add)){
int one = Integer.parseInt(num1.getText());
int two = Integer.parseInt(num2.getText());
int res = one + two;
ra.setText(res +"");
}
}
}4
 Complete the tabbed panel created in class. Build the division and

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!