Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having trouble with my code for a java program. Can somebody please help me

ID: 3621630 • Letter: I

Question

I am having trouble with my code for a java program. Can somebody please help me figure this out.

Project specifications require that the GUI, as given below, must contain a numeric keypad, similar to that on a cell phone, where the user can only click decimals digits and a decimal point for keying in real numbers.

Here is how they want the "regions" set up. Feel free to do it how ever you want to make it look like the picture.

Program GUI—contains a JFrame with layout set to BorderLayout (NORTH, SOUTH, EAST & CENTER regions). The WEST region is not used in this solution.
NORTH region -- contains a JPanel (suggest using a BoxLayout) with one JLabel added to display a digit string, possibly including a decimal point, which are appended to the string by clicking the buttons on the keypad.
CENTER region -- contains a JPanel (suggest using a GridLayout) with 12 JButtons added and arranged in 4 rows and 3 columns.
EAST region -- contains a JPanel with a JButton (clear button) added.
SOUTH region -- contains a JPanel (suggest using a GridLayout) to arrange six JLabels and three JButtons as the controls placed in the lower area of the GUI.


This is what the final outcome should look like below



Explanation / Answer

import javax.swing.*; import javax.swing.event.*; import java.io.*; import java.awt.*; import java.awt.event.*; public class calc extends JFrame{ JPanel top, mid, bot,mid1,mid2,bot1,bot2; JButton buttons[], clear,miles, gallons, save; JLabel l1,l2,l3; Container c; JTextField str; public calc() { top = new JPanel(); mid = new JPanel(); bot = new JPanel(); mid1 = new JPanel(new GridLayout(4,3)); mid2 = new JPanel(); bot1 = new JPanel(new GridLayout(3,1)); bot2 = new JPanel(new GridLayout(3,1)); c = getContentPane(); buttons = new JButton[12]; for(int i=0;i