SlideShare a Scribd company logo
1 of 3
Download to read offline
Value isn't changing and I can't seem to get the conversion to work.package UI;import
java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import
javax.swing.*;import javax.swing.event.ChangeEvent;import
javax.swing.event.ChangeListener;public class HeightConverterFrame extends JFrame
implements ActionListener, ChangeListener {private JTextField heightCmField; // Holds height
output value in cmprivate JTextField heightFtField; // Holds height input value in feetprivate
JTextField heightInField; // Holds heigth input value in inchesprivate JLabel feetLabel; // Label
for heigth input in feetprivate JLabel inchesLabel; // Label for height input in inchesprivate
JLabel cmLabel; // Label for heigth in cmprivate JButton convertButton; // Triggers heigth
conversionprivate JSlider heightFtSlider; // Slider for feet inputprivate JSlider heightInSlider; //
Slider for inches inputfinal static double CM_PER_IN = 2.54; // Centimeters per inchfinal static
int IN_PER_FT = 12; //inch per foot/*constructor creates GUI components. It adds GUI
componentsusing a GridBagLayout*/HeightConverterFrame(){int feetMin = 0; //feet slider min
valueint feetMax = 10; //feet slider max valueint feetInch = 5; //feet slider initial valueint feetInit
= 5; // feet slider intial valueint inchesMin = 0;int inchesMax = 11;int inchesInit = 8; // inches
slider intial valueGridBagConstraints layoutConst = null; // GUI component layout//set frame
titlesetTitle("Height converter");//Create labelsfeetLabel = new JLabel("enter feet");inchesLabel
= new JLabel("enter inches");cmLabel = new JLabel("centimeters");heightCmField = new
JTextField(10);heightCmField.setEnabled(false);convertButton = new
JButton("convert");convertButton.addActionListener(this);//create slider that enables user to
enter height in feetheightFtSlider = new JSlider(feetMin, feetMax,
feetInit);heightFtSlider.addChangeListener(this);heightFtSlider.setMajorTickSpacing(10);height
FtSlider.setMinorTickSpacing(1);heightFtSlider.setPaintTicks(true);heightFtSlider.setPaintLabel
s(true);heightFtField = new
JTextField(10);heightFtField.setEditable(false);heightFtField.setText("5");//create slider that
enables user to enter height in inchesheightInSlider = new JSlider(inchesMin, inchesMax,
inchesInit);heightInSlider.addChangeListener(this);heightInSlider.setMajorTickSpacing(10);heig
htInSlider.setMinorTickSpacing(1);heightInSlider.setPaintTicks(true);heightInSlider.setPaintLab
els(true);heightInField = new
JTextField(10);heightInField.setEditable(false);heightInField.setText("8");// create frame and
add components using GridBaglayoutsetLayout(new GridBagLayout());//01layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(10, 10, 1, 1);layoutConst.anchor =
GridBagConstraints.LINE_START;layoutConst.gridx = 0;layoutConst.gridy =
0;layoutConst.gridwidth = 1;add(feetLabel, layoutConst);//02layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(10, 10, 1, 1);layoutConst.anchor =
GridBagConstraints.LINE_START;layoutConst.gridx = 2;layoutConst.gridy =
0;layoutConst.gridwidth = 1;add(inchesLabel, layoutConst);//03layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(10, 1, 1, 10);layoutConst.fill =
GridBagConstraints.HORIZONTAL;layoutConst.gridx = 1;layoutConst.gridy =
0;layoutConst.gridwidth = 1;add(heightFtField, layoutConst);//04layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(10, 10, 1, 10);layoutConst.fill =
GridBagConstraints.HORIZONTAL;layoutConst.gridx = 3;layoutConst.gridy =
0;layoutConst.gridwidth = 1;add(heightInField, layoutConst);//05layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(1, 10, 10, 10);layoutConst.fill =
GridBagConstraints.HORIZONTAL;layoutConst.gridx = 0;layoutConst.gridy =
1;layoutConst.gridwidth = 2;add(heightFtSlider, layoutConst);//06layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(1, 10, 10, 10);layoutConst.fill =
GridBagConstraints.HORIZONTAL;layoutConst.gridx = 2;layoutConst.gridy =
1;layoutConst.gridwidth = 2;add(heightInSlider, layoutConst);//07layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(10, 10, 10, 5);layoutConst.anchor =
GridBagConstraints.LINE_END;layoutConst.gridx = 0;layoutConst.gridy =
2;layoutConst.gridwidth = 1;add(convertButton, layoutConst);//08layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(10, 10, 10, 1);layoutConst.anchor =
GridBagConstraints.LINE_END;layoutConst.gridx = 1;layoutConst.gridy =
2;layoutConst.gridwidth = 1;add(cmLabel, layoutConst);//09layoutConst = new
GridBagConstraints();layoutConst.insets = new Insets(10, 1, 10, 10);layoutConst.fill =
GridBagConstraints.HORIZONTAL;layoutConst.gridx = 2;layoutConst.gridy =
2;layoutConst.gridwidth = 2;add(heightCmField, layoutConst);}/* converts a height in feet/
inches to centimeters*/public static double HeightFtInToCm(int ft, int in){int totIn;double
cmHeight;totIn = (ft * IN_PER_FT) + in; //total inchescmHeight = totIn * CM_PER_IN; //
convert to cmreturn cmHeight;}//called as slider value changes. Update field to
display//conversion of numerical value@Overridepublic void stateChanged(ChangeEvent
event){int sliderVal;String strSliderVal;JSlider sourceEvent = (JSlider)
event.getSource();if(sourceEvent == heightFtSlider){sliderVal =
heightFtSlider.getValue();strSliderVal = Integer.toString(sliderVal);} else if(sourceEvent ==
heightInSlider){sliderVal = heightInSlider.getValue();strSliderVal =
Integer.toString(sliderVal);heightInField.setText(strSliderVal);}}public static void main(String[]
args) {HeightConverterFrame myFrame = new
HeightConverterFrame();myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);myFr
ame.pack();myFrame.setVisible(true);}@Overridepublic void actionPerformed(ActionEvent e)
{}}

More Related Content

Similar to Convert height values to cm

package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfsudhirchourasia86
 
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdfimport java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdfvenkt12345
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptKaty Slemon
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads France
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to GriffonJames Williams
 
Creating an Uber Clone - Part XIX - Transcript.pdf
Creating an Uber Clone - Part XIX - Transcript.pdfCreating an Uber Clone - Part XIX - Transcript.pdf
Creating an Uber Clone - Part XIX - Transcript.pdfShaiAlmog1
 
Famo.us: From Zero to UI
Famo.us: From Zero to UIFamo.us: From Zero to UI
Famo.us: From Zero to UItimjchin
 
[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023
[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023
[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023Johnny Sung
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to HooksSoluto
 
Gutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisablesGutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisablesRiad Benguella
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfarvindarora20042013
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdffathimaoptical
 
react-hooks.pdf
react-hooks.pdfreact-hooks.pdf
react-hooks.pdfchengbo xu
 

Similar to Convert height values to cm (20)

package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
 
Qt Workshop
Qt WorkshopQt Workshop
Qt Workshop
 
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdfimport java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
How to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescriptHow to build to do app using vue composition api and vuex 4 with typescript
How to build to do app using vue composition api and vuex 4 with typescript
 
CocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIViewCocoaHeads Toulouse - Guillaume Cerquant - UIView
CocoaHeads Toulouse - Guillaume Cerquant - UIView
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
 
004
004004
004
 
Creating an Uber Clone - Part XIX - Transcript.pdf
Creating an Uber Clone - Part XIX - Transcript.pdfCreating an Uber Clone - Part XIX - Transcript.pdf
Creating an Uber Clone - Part XIX - Transcript.pdf
 
ch20.pptx
ch20.pptxch20.pptx
ch20.pptx
 
Famo.us: From Zero to UI
Famo.us: From Zero to UIFamo.us: From Zero to UI
Famo.us: From Zero to UI
 
[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023
[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023
[Flutter] Flutter Provider 看似簡單卻又不簡單的狀態管理工具 @ Devfest Kaohsiung 2023
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
Gutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisablesGutenberg sous le capot, modules réutilisables
Gutenberg sous le capot, modules réutilisables
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
 
From Swing to JavaFX
From Swing to JavaFXFrom Swing to JavaFX
From Swing to JavaFX
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdf
 
react-hooks.pdf
react-hooks.pdfreact-hooks.pdf
react-hooks.pdf
 
Angular 2.0 - What to expect
Angular 2.0 - What to expectAngular 2.0 - What to expect
Angular 2.0 - What to expect
 
Day 5
Day 5Day 5
Day 5
 

More from amirthagiftsmadurai

value if lifo for its inverntory. the inventory on12312020 was $70.pdf
value if lifo for its inverntory. the inventory on12312020 was $70.pdfvalue if lifo for its inverntory. the inventory on12312020 was $70.pdf
value if lifo for its inverntory. the inventory on12312020 was $70.pdfamirthagiftsmadurai
 
Utilizando los datos comerciales del Observatorio de Complejidad Eco.pdf
Utilizando los datos comerciales del Observatorio de Complejidad Eco.pdfUtilizando los datos comerciales del Observatorio de Complejidad Eco.pdf
Utilizando los datos comerciales del Observatorio de Complejidad Eco.pdfamirthagiftsmadurai
 
using the code below create a method called getCollisionCount that w.pdf
using the code below create a method called getCollisionCount that w.pdfusing the code below create a method called getCollisionCount that w.pdf
using the code below create a method called getCollisionCount that w.pdfamirthagiftsmadurai
 
Usted es accionista del 5 de Company XYZ, Inc. La compa��a planea .pdf
Usted es accionista del 5  de Company XYZ, Inc. La compa��a planea .pdfUsted es accionista del 5  de Company XYZ, Inc. La compa��a planea .pdf
Usted es accionista del 5 de Company XYZ, Inc. La compa��a planea .pdfamirthagiftsmadurai
 
Using this example code in Xcode, please help with this project wher.pdf
Using this example code in Xcode, please help with this project wher.pdfUsing this example code in Xcode, please help with this project wher.pdf
Using this example code in Xcode, please help with this project wher.pdfamirthagiftsmadurai
 
using the the periodic method what is the journal entryusing th.pdf
using the the periodic method what is the journal entryusing th.pdfusing the the periodic method what is the journal entryusing th.pdf
using the the periodic method what is the journal entryusing th.pdfamirthagiftsmadurai
 
Using the properties of Regular languages, mention which properties .pdf
Using the properties of Regular languages, mention which properties .pdfUsing the properties of Regular languages, mention which properties .pdf
Using the properties of Regular languages, mention which properties .pdfamirthagiftsmadurai
 
Using the information displayed on the table below, calculate the Un.pdf
Using the information displayed on the table below, calculate the Un.pdfUsing the information displayed on the table below, calculate the Un.pdf
Using the information displayed on the table below, calculate the Un.pdfamirthagiftsmadurai
 
using the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdfusing the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdfamirthagiftsmadurai
 
Using the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdfUsing the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdfamirthagiftsmadurai
 
Using the accidentdata dataset how to conduct a comprehensive EDA .pdf
Using the accidentdata dataset  how to conduct a comprehensive EDA .pdfUsing the accidentdata dataset  how to conduct a comprehensive EDA .pdf
Using the accidentdata dataset how to conduct a comprehensive EDA .pdfamirthagiftsmadurai
 
Vuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdf
Vuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdfVuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdf
Vuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdfamirthagiftsmadurai
 
Vuelve a escribir las oraciones usando los verbos provistos entre pa.pdf
Vuelve a escribir las oraciones usando los verbos provistos entre pa.pdfVuelve a escribir las oraciones usando los verbos provistos entre pa.pdf
Vuelve a escribir las oraciones usando los verbos provistos entre pa.pdfamirthagiftsmadurai
 
We aim to upgrade the function �insert� of the class orderedLinkedLi.pdf
We aim to upgrade the function �insert� of the class orderedLinkedLi.pdfWe aim to upgrade the function �insert� of the class orderedLinkedLi.pdf
We aim to upgrade the function �insert� of the class orderedLinkedLi.pdfamirthagiftsmadurai
 
Verdadero o falso 7. Los errores son errores no intencionales. .pdf
Verdadero o falso 7. Los errores son errores no intencionales. .pdfVerdadero o falso 7. Los errores son errores no intencionales. .pdf
Verdadero o falso 7. Los errores son errores no intencionales. .pdfamirthagiftsmadurai
 
Verdadero o falso todas las especies, independientemente de los tax.pdf
Verdadero o falso todas las especies, independientemente de los tax.pdfVerdadero o falso todas las especies, independientemente de los tax.pdf
Verdadero o falso todas las especies, independientemente de los tax.pdfamirthagiftsmadurai
 
Warren Buffy is an enormously wealthy investor who has built his for.pdf
Warren Buffy is an enormously wealthy investor who has built his for.pdfWarren Buffy is an enormously wealthy investor who has built his for.pdf
Warren Buffy is an enormously wealthy investor who has built his for.pdfamirthagiftsmadurai
 
Watch Podcast SpanxWrite a response to the podcast using the cor.pdf
Watch Podcast SpanxWrite a response to the podcast using the cor.pdfWatch Podcast SpanxWrite a response to the podcast using the cor.pdf
Watch Podcast SpanxWrite a response to the podcast using the cor.pdfamirthagiftsmadurai
 
Vincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdf
Vincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdfVincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdf
Vincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdfamirthagiftsmadurai
 
Wanda, a retired electrical engineer, suffered a stroke, Her memorie.pdf
Wanda, a retired electrical engineer, suffered a stroke, Her memorie.pdfWanda, a retired electrical engineer, suffered a stroke, Her memorie.pdf
Wanda, a retired electrical engineer, suffered a stroke, Her memorie.pdfamirthagiftsmadurai
 

More from amirthagiftsmadurai (20)

value if lifo for its inverntory. the inventory on12312020 was $70.pdf
value if lifo for its inverntory. the inventory on12312020 was $70.pdfvalue if lifo for its inverntory. the inventory on12312020 was $70.pdf
value if lifo for its inverntory. the inventory on12312020 was $70.pdf
 
Utilizando los datos comerciales del Observatorio de Complejidad Eco.pdf
Utilizando los datos comerciales del Observatorio de Complejidad Eco.pdfUtilizando los datos comerciales del Observatorio de Complejidad Eco.pdf
Utilizando los datos comerciales del Observatorio de Complejidad Eco.pdf
 
using the code below create a method called getCollisionCount that w.pdf
using the code below create a method called getCollisionCount that w.pdfusing the code below create a method called getCollisionCount that w.pdf
using the code below create a method called getCollisionCount that w.pdf
 
Usted es accionista del 5 de Company XYZ, Inc. La compa��a planea .pdf
Usted es accionista del 5  de Company XYZ, Inc. La compa��a planea .pdfUsted es accionista del 5  de Company XYZ, Inc. La compa��a planea .pdf
Usted es accionista del 5 de Company XYZ, Inc. La compa��a planea .pdf
 
Using this example code in Xcode, please help with this project wher.pdf
Using this example code in Xcode, please help with this project wher.pdfUsing this example code in Xcode, please help with this project wher.pdf
Using this example code in Xcode, please help with this project wher.pdf
 
using the the periodic method what is the journal entryusing th.pdf
using the the periodic method what is the journal entryusing th.pdfusing the the periodic method what is the journal entryusing th.pdf
using the the periodic method what is the journal entryusing th.pdf
 
Using the properties of Regular languages, mention which properties .pdf
Using the properties of Regular languages, mention which properties .pdfUsing the properties of Regular languages, mention which properties .pdf
Using the properties of Regular languages, mention which properties .pdf
 
Using the information displayed on the table below, calculate the Un.pdf
Using the information displayed on the table below, calculate the Un.pdfUsing the information displayed on the table below, calculate the Un.pdf
Using the information displayed on the table below, calculate the Un.pdf
 
using the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdfusing the code below write the public V add(K key, V value); that ad.pdf
using the code below write the public V add(K key, V value); that ad.pdf
 
Using the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdfUsing the Ceasar Cipher encryption algorithm, you take each characte.pdf
Using the Ceasar Cipher encryption algorithm, you take each characte.pdf
 
Using the accidentdata dataset how to conduct a comprehensive EDA .pdf
Using the accidentdata dataset  how to conduct a comprehensive EDA .pdfUsing the accidentdata dataset  how to conduct a comprehensive EDA .pdf
Using the accidentdata dataset how to conduct a comprehensive EDA .pdf
 
Vuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdf
Vuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdfVuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdf
Vuelva a resolver el problema 15 de la secci�n 2.2 de su texto, que .pdf
 
Vuelve a escribir las oraciones usando los verbos provistos entre pa.pdf
Vuelve a escribir las oraciones usando los verbos provistos entre pa.pdfVuelve a escribir las oraciones usando los verbos provistos entre pa.pdf
Vuelve a escribir las oraciones usando los verbos provistos entre pa.pdf
 
We aim to upgrade the function �insert� of the class orderedLinkedLi.pdf
We aim to upgrade the function �insert� of the class orderedLinkedLi.pdfWe aim to upgrade the function �insert� of the class orderedLinkedLi.pdf
We aim to upgrade the function �insert� of the class orderedLinkedLi.pdf
 
Verdadero o falso 7. Los errores son errores no intencionales. .pdf
Verdadero o falso 7. Los errores son errores no intencionales. .pdfVerdadero o falso 7. Los errores son errores no intencionales. .pdf
Verdadero o falso 7. Los errores son errores no intencionales. .pdf
 
Verdadero o falso todas las especies, independientemente de los tax.pdf
Verdadero o falso todas las especies, independientemente de los tax.pdfVerdadero o falso todas las especies, independientemente de los tax.pdf
Verdadero o falso todas las especies, independientemente de los tax.pdf
 
Warren Buffy is an enormously wealthy investor who has built his for.pdf
Warren Buffy is an enormously wealthy investor who has built his for.pdfWarren Buffy is an enormously wealthy investor who has built his for.pdf
Warren Buffy is an enormously wealthy investor who has built his for.pdf
 
Watch Podcast SpanxWrite a response to the podcast using the cor.pdf
Watch Podcast SpanxWrite a response to the podcast using the cor.pdfWatch Podcast SpanxWrite a response to the podcast using the cor.pdf
Watch Podcast SpanxWrite a response to the podcast using the cor.pdf
 
Vincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdf
Vincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdfVincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdf
Vincent van Gogh es uno de los artistas postimpresionistas m�s conoc.pdf
 
Wanda, a retired electrical engineer, suffered a stroke, Her memorie.pdf
Wanda, a retired electrical engineer, suffered a stroke, Her memorie.pdfWanda, a retired electrical engineer, suffered a stroke, Her memorie.pdf
Wanda, a retired electrical engineer, suffered a stroke, Her memorie.pdf
 

Recently uploaded

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Recently uploaded (20)

Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

Convert height values to cm

  • 1. Value isn't changing and I can't seem to get the conversion to work.package UI;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;public class HeightConverterFrame extends JFrame implements ActionListener, ChangeListener {private JTextField heightCmField; // Holds height output value in cmprivate JTextField heightFtField; // Holds height input value in feetprivate JTextField heightInField; // Holds heigth input value in inchesprivate JLabel feetLabel; // Label for heigth input in feetprivate JLabel inchesLabel; // Label for height input in inchesprivate JLabel cmLabel; // Label for heigth in cmprivate JButton convertButton; // Triggers heigth conversionprivate JSlider heightFtSlider; // Slider for feet inputprivate JSlider heightInSlider; // Slider for inches inputfinal static double CM_PER_IN = 2.54; // Centimeters per inchfinal static int IN_PER_FT = 12; //inch per foot/*constructor creates GUI components. It adds GUI componentsusing a GridBagLayout*/HeightConverterFrame(){int feetMin = 0; //feet slider min valueint feetMax = 10; //feet slider max valueint feetInch = 5; //feet slider initial valueint feetInit = 5; // feet slider intial valueint inchesMin = 0;int inchesMax = 11;int inchesInit = 8; // inches slider intial valueGridBagConstraints layoutConst = null; // GUI component layout//set frame titlesetTitle("Height converter");//Create labelsfeetLabel = new JLabel("enter feet");inchesLabel = new JLabel("enter inches");cmLabel = new JLabel("centimeters");heightCmField = new JTextField(10);heightCmField.setEnabled(false);convertButton = new JButton("convert");convertButton.addActionListener(this);//create slider that enables user to enter height in feetheightFtSlider = new JSlider(feetMin, feetMax, feetInit);heightFtSlider.addChangeListener(this);heightFtSlider.setMajorTickSpacing(10);height FtSlider.setMinorTickSpacing(1);heightFtSlider.setPaintTicks(true);heightFtSlider.setPaintLabel s(true);heightFtField = new JTextField(10);heightFtField.setEditable(false);heightFtField.setText("5");//create slider that enables user to enter height in inchesheightInSlider = new JSlider(inchesMin, inchesMax, inchesInit);heightInSlider.addChangeListener(this);heightInSlider.setMajorTickSpacing(10);heig htInSlider.setMinorTickSpacing(1);heightInSlider.setPaintTicks(true);heightInSlider.setPaintLab els(true);heightInField = new JTextField(10);heightInField.setEditable(false);heightInField.setText("8");// create frame and add components using GridBaglayoutsetLayout(new GridBagLayout());//01layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(10, 10, 1, 1);layoutConst.anchor = GridBagConstraints.LINE_START;layoutConst.gridx = 0;layoutConst.gridy = 0;layoutConst.gridwidth = 1;add(feetLabel, layoutConst);//02layoutConst = new
  • 2. GridBagConstraints();layoutConst.insets = new Insets(10, 10, 1, 1);layoutConst.anchor = GridBagConstraints.LINE_START;layoutConst.gridx = 2;layoutConst.gridy = 0;layoutConst.gridwidth = 1;add(inchesLabel, layoutConst);//03layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(10, 1, 1, 10);layoutConst.fill = GridBagConstraints.HORIZONTAL;layoutConst.gridx = 1;layoutConst.gridy = 0;layoutConst.gridwidth = 1;add(heightFtField, layoutConst);//04layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(10, 10, 1, 10);layoutConst.fill = GridBagConstraints.HORIZONTAL;layoutConst.gridx = 3;layoutConst.gridy = 0;layoutConst.gridwidth = 1;add(heightInField, layoutConst);//05layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(1, 10, 10, 10);layoutConst.fill = GridBagConstraints.HORIZONTAL;layoutConst.gridx = 0;layoutConst.gridy = 1;layoutConst.gridwidth = 2;add(heightFtSlider, layoutConst);//06layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(1, 10, 10, 10);layoutConst.fill = GridBagConstraints.HORIZONTAL;layoutConst.gridx = 2;layoutConst.gridy = 1;layoutConst.gridwidth = 2;add(heightInSlider, layoutConst);//07layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(10, 10, 10, 5);layoutConst.anchor = GridBagConstraints.LINE_END;layoutConst.gridx = 0;layoutConst.gridy = 2;layoutConst.gridwidth = 1;add(convertButton, layoutConst);//08layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(10, 10, 10, 1);layoutConst.anchor = GridBagConstraints.LINE_END;layoutConst.gridx = 1;layoutConst.gridy = 2;layoutConst.gridwidth = 1;add(cmLabel, layoutConst);//09layoutConst = new GridBagConstraints();layoutConst.insets = new Insets(10, 1, 10, 10);layoutConst.fill = GridBagConstraints.HORIZONTAL;layoutConst.gridx = 2;layoutConst.gridy = 2;layoutConst.gridwidth = 2;add(heightCmField, layoutConst);}/* converts a height in feet/ inches to centimeters*/public static double HeightFtInToCm(int ft, int in){int totIn;double cmHeight;totIn = (ft * IN_PER_FT) + in; //total inchescmHeight = totIn * CM_PER_IN; // convert to cmreturn cmHeight;}//called as slider value changes. Update field to display//conversion of numerical value@Overridepublic void stateChanged(ChangeEvent event){int sliderVal;String strSliderVal;JSlider sourceEvent = (JSlider) event.getSource();if(sourceEvent == heightFtSlider){sliderVal = heightFtSlider.getValue();strSliderVal = Integer.toString(sliderVal);} else if(sourceEvent == heightInSlider){sliderVal = heightInSlider.getValue();strSliderVal = Integer.toString(sliderVal);heightInField.setText(strSliderVal);}}public static void main(String[] args) {HeightConverterFrame myFrame = new HeightConverterFrame();myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);myFr ame.pack();myFrame.setVisible(true);}@Overridepublic void actionPerformed(ActionEvent e)
  • 3. {}}