I got everything done on my program with a couple minor issues...first my clear button in the menu exits my program and my exit the program button does not do anything and everything looks right on my end...the other issue is I am getting two errors in the parsing and it looks right to me but I guess I am doing something wrong:


1. 4 Labels (align them to the right by using the parameter Label.RIGHT when you construct your label… Label lengthLabel = new Label(“Enter the length: “, Label.RIGHT)
2. 4 TextFields (2 for input and 2 for output… your output fields should be read-only). All of your TextFields can be length 10.
3. 2 Buttons… one to calculate the area and perimeter and one to exit… use the labels for the buttons shown below
area = length * width
perimeter = 2 * (length + width)
4. create a menu for File -> Exit (to terminate the application)
5. create a menu for Edit -> Clear (to clear all TextFields)
6. only calculate/display the area and perimeter if length and width are valid and greater than zero… if not, display an error message in a dialog box, clear out all TextFields, and put the cursor in the length field.
7. when you click the Calculate button, be sure all 4 values in the TextFields are formatted to two decimal places with a comma in the thousands place (see below)
8. be sure to include code to terminate the application when the X is clicked
9. use a GridLayout for the frame with 5 rows, 2 columns, and 5 pixels for spacing horizontally and vertically
10. utilize the setActionCommand() method to allow for only one “exit” section of code in your actionPerformed() method
11. have the Frame display in the center of the monitor with a width of 350 and height of 200
12. have the Frame title of “Area and Perimeter of a Rectangle”

//import packages
import java.awt.*;
import java.awt.event.*;
import java.awt.datatransfer.*;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;

//create a subclass at the fram class
public class RectangleApp extends Frame implements ActionListener
	//construct variables
	private Label lengthLabel = new Label("Enter the length: ", Label.RIGHT);
	private Label widthLabel = new Label("Enter the width: ", Label.RIGHT);
	private Label areaLabel = new Label("Area: ", Label.RIGHT);
	private Label perimeterLabel = new Label("Perimeter: ", Label.RIGHT);
	private Panel topPanel;
	private Button calculateButton = new Button("Calculate");
	private Button exitButton = new Button("Exit the Program");
	private TextField lengthField = new TextField(10);
	private TextField widthField = new TextField(10);
	private TextField areaField = new TextField(10);
	private TextField perimeterField = new TextField(10);
	private boolean first;
	private boolean clearText;
	private DecimalFormat calcPattern;
	private double length;
	private double width;
	private double area;
	private double perimeter;

	//constructor method
	public RectangleApp()
		//create an instance of the menu
		MenuBar mnuBar = new MenuBar();
		setMenuBar(mnuBar); //display the previously constructed MenuBar

		//construct and populate File Menu
		Menu mnuFile = new Menu("File"); //create a command on the MenuBar
		MenuItem mnuFileExit = new MenuItem("Exit");

		//construct a command to go under a menu

		//construct and populate the edit menu
		Menu mnuEdit = new Menu("Edit");
		MenuItem mnuEditClear = new MenuItem("Clear");

		//register the action listener with each of the menuitems

		//assign an ActionCommand to each of the MenuItems

		//construct components and initialize beginning values
		topPanel = new Panel();
		calcPattern = new DecimalFormat("###,###.##");
		length = 0.0;
		width = 0.0;
		area = 0.0;
		perimeter = 0.0;

		//set layouts for the Frame and Panels
		setLayout(new BorderLayout());
		topPanel.setLayout(new GridLayout(5, 2, 5, 5));

		//add components to frame
		add(topPanel, BorderLayout.NORTH);

		//allow the x to close the application
		addWindowListener(new WindowAdapter()
			public void windowClosing(WindowEvent e)
		} //end window adapter
	} //end calculator[] constructor method
		public static void main(String args [])
			//construct an instance of the Frame (Calculator)
			RectangleApp f = new RectangleApp();
			f.setTitle("Area and Perimeter of a Rectangle");
			f.setSize(350, 200);
		} //end main
		public void actionPerformed(ActionEvent e)
			//test for menu item clicks
			String arg = e.getActionCommand();

		//exit was clicked
		if(arg == "Exit");

		//clear was clikced
			clearText = true;
			first = true;

		} //end if about

		//Calculate button was clicked

			convert data in TextField to int
			double length = Double.parseDouble(lengthField.getText());
			double width = Double.parseDouble(widthField.getText());
			double area = Double.parseDouble(areaField.getText());
			double perimeter = Double.parseDouble(perimeterField.getText());
			area = length * width;
			perimeter = length + width;
		} //end the if go

		//exitbutton was clicked
		if(arg.equals("Exit the program"))
		} //end the if exit

	} //end action performed
} //end class
by the way I know I have not done error checking just wanna make sure everything is right first before I check for errors