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 JTabbedPaneJTabbedPaneLEFT;
JPanel addP new JPanel;
JPanel subP new JPanel;
JPanel mulP new JPanel;
JPanel divP new JPanel;
Add the inputted numbers
JTextField num new JTextField;
JTextField num new JTextField;
JTextField ra new JTextField;
JLabel number new JLabelNumber ;
JLabel number new JLabelNumber ;
JLabel resulta new JLabelresult;
Subtract the inputted numbers
JTextField num new JTextField;
JTextField num new JTextField;
JTextField rs new JTextField;
JLabel numbers new JLabelNumber ;
JLabel numbers new JLabelNumber ;
JLabel results new JLabelresult;
Multiply the inputted numbers
JTextField num new JTextField;
JTextField num new JTextField;
JTextField rm new JTextField;
JLabel numberm new JLabelNumber ;
JLabel numberm new JLabelNumber ;
JLabel resultm new JLabelresult;
Divide the inputted numbers
JTextField num new JTextField;
JTextField num new JTextField;
JTextField rd new JTextField;
JLabel numberd new JLabelNumber ;
JLabel numberd new JLabelNumber ;
JLabel resultd new JLabelresult;
JButton add new JButtonadd;
JButton subtract new JButtonsubtract;
JButton multiply new JButtonmultiply;
JButton divide new JButtondivide;
public TabbedGUI
ActionListener
add.addActionListenerthis;
subtract.addActionListenerthis;
multiply.addActionListenerthis;
divide.addActionListenerthis;
Addition SubPanel layout
addP.setLayoutnew GridLayout;
addP.addnumber;
addP.addnum;
addP.addnumber;
addP.addnum;
addP.addresulta;
addP.addra;
addP.addadd;
ImageIcon plus new ImageIconimagespluspng;
tabbedPane.addTabAdd plus, addP, "Click to add numbers";
tabbedPane.setMnemonicAt KeyEvent.VK;
Subtraction SubPanel layout
subP.setLayoutnew GridLayout;
subP.addnumbers;
subP.addnum;
subP.addnumbers;
subP.addnum;
subP.addresults;
subP.addrs;
subP.addsubtract;
ImageIcon minus new ImageIconimagessubtractpng;
tabbedPane.addTabSubtract minus, subP, "Click to subtract numbers";
tabbedPane.setMnemonicAt KeyEvent.VK;
Add to Frame
this.setDefaultCloseOperationDISPOSEONCLOSE;
this.getContentPaneaddtabbedPane;
this.setPreferredSizenew Dimension;
this.setVisibletrue;
this.pack;
Action Listener
@Override
public void actionPerformedActionEvent e
ifegetSourceequalsadd
int one Integer.parseIntnumgetText;
int two Integer.parseIntnumgetText;
int res one two;
rasetTextres ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
