MeasureConversion - centimeterHandler = new CentHandler();

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

View Full Document Right Arrow Icon
import javax.swing.*; import java.awt.event.*; import java.awt.*; i public class MeasureConversion extends JFrame { private JLabel inchL,centimeterL; private JTextField inchTF,centimeterTF; private InchHandler inchHandler; private CentHandler centimeterHandler; p private static final int WIDTH = 500; private static final int HEIGHT = 100; private static final double InchToCentimeter = 3.08; private static final double CentimeterToInch = 0.56; p public MeasureConversion() { setTitle ("Jamel Jenkins 10/26/08"); Container ic = getContentPane(); ic.setLayout(new GridLayout(1,4)); inchL = new JLabel("Conversion of Inches in Centimeters: ",SwingConstants.RIGHT); centimeterL = new JLabel("Conversion of Centimeters in Inches: ",SwingConstants.RIGHT); inchTF = new JTextField(10); centimeterTF = new JTextField(10); ic.add(inchL); ic.add(inchTF); ic.add(centimeterL); ic.add(centimeterTF); inchHandler = new InchHandler();
Background image of page 1

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

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

Unformatted text preview: centimeterHandler = new CentHandler(); inchTF.addActionListener(inchHandler); centimeterTF.addActionListener(centimeterHandler); setSize(WIDTH, HEIGHT); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); } private class InchHandler implements ActionListener { public void actionPerformed(ActionEvent s) { double inch; double centimeter; inch = Double.parseDouble(inchTF.getText()); centimeter = inch * InchToCentimeter; centimeterTF.setText(String.format("%.2f",centimeter)); }} private class CentHandler implements ActionListener { public void actionPerformed(ActionEvent s) { double inch; double centimeter; centimeter = Double.parseDouble(centimeterTF.getText()); inch = centimeter * CentimeterToInch; inchTF.setText(String.format("%.2f",inch)); }} public static void main(String args) { MeasureConversion measureCon = new MeasureConversion(); }} }...
View Full Document

This note was uploaded on 10/04/2010 for the course COMPUTER S 106 taught by Professor Moore during the Spring '08 term at Clark Atlanta.

Page1 / 2

MeasureConversion - centimeterHandler = new CentHandler();

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