TemperatureConversion - Container ic = getContentPane();...

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

View Full Document Right Arrow Icon
//Jamel Jenkins // Pgs.353 #8 import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MeasureConversion extends JFrame { private JLabel centimeterL, inchL; private JTextField centimeterTF, inchTF; private CentimeterHandler centimeterHandler; private InchHandler inchHandler; p private static final int WIDTH = 500; private static final int HEIGHT = 50; private static final double InchToCent = 3.08; private static final double CentToInch = 0.56; p public class MeasureConversion() { setTitle("Jamel Jenkins 10/26/08"); centimeterL = new JLabel("Coversion of Inches to Centimeters: ", SwingConstants.RIGHT); inchL = new JLabel ("Conversion of Centimeters to Inches: ", SwingConstants.RIGHT); centimeterTF = new JTextField(10); inchTF = new JTextField(10); centimeterHandler = new CentimeterHandler(); centimeterTF.addActionListerner(centimeterHandler); inchHandler = new InchHandler(); inchTF.addActionListerner(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: Container ic = getContentPane(); ic.setLayout(new GridLayout(1, 4)); ic.add(centimeterL); ic.add(centimeterTF); ic.add(inchL); ic.add(inchTF); setSize(WIDTH,HEIGHT); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } private class InchHandler implements ActionListener { public void actionPerformed(ActionEvent s) { double inch; double centimeter; inch = Double.parseDouble(inchTF.getText()); centimeter = inch * InchToCent; centimeterTF.setText(String.format("%.2f",centimeter)); }} private class CentimeterHandler implements ActionListener { public void actionPerformed(ActionEvent s) { double inch; double centimeter; centimeter = Double.parseDouble(centimeterTF.getText()); inch = centimeter * CentToInch; inchTF.setText(String.format("%.2f",inch)); }} public static void main(String args); { MeasureConversion MeaCon = new MeasureConversion(); M System.exit(0); }}...
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

TemperatureConversion - Container ic = getContentPane();...

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