RectangleProgram - /Given the length and width of a...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
///Given the length and width of a rectangle, this Java //program determines its area and perimeter. / import javax.swing.*; import java.awt.*; import java.awt.event.*; i public class RectangleProgram extends JFrame { private JLabel lengthL, widthL, areaL, perimeterL; private JTextField lengthTF, widthTF, areaTF, perimeterTF; private JButton calculateB, exitB; private CalculateButtonHandler cbHandler; private ExitButtonHandler ebHandler; private static final int WIDTH = 400; private static final int HEIGHT = 300; public RectangleProgram() { //Create the four labels lengthL = new JLabel("Enter the length: ", SwingConstants.RIGHT); widthL = new JLabel("Enter the width: ", SwingConstants.RIGHT); areaL = new JLabel("Area: ", SwingConstants.RIGHT); perimeterL = new JLabel("Perimeter: ", SwingConstants.RIGHT); //Create the four text fields lengthTF = new JTextField(10); widthTF = new JTextField(10); areaTF = new JTextField(10); perimeterTF = new JTextField(10); //Create Calculate Button calculateB = new JButton("Calculate");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Page1 / 2

RectangleProgram - /Given the length and width of a...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online