Skip to content

Commit

Permalink
make celsius converter work provisionally
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingo60 committed Oct 7, 2014
1 parent e78f8e3 commit 1509c06
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions examples/SwingExamples.fr
Expand Up @@ -19,21 +19,28 @@ celsiusConverterGUI = do
frame <- JFrame.new ()
frame.setDefaultCloseOperation JFrame.dispose_on_close
frame.setTitle "Celsius Converter"
celsiusLabel.setText "Celsius"
convertButton.setText "Convert"
tempTextField.setText "0.000"
JLabel.setText celsiusLabel "Celsius"
AbstractButton.setText convertButton "Convert"
let convertButtonActionPerformed _ = do
celsius <- tempTextField.getText
case celsius.double of
Left _ -> fahrenheitLabel.setText ("not a valid number: " ++ celsius)
Right c -> fahrenheitLabel.setText (show (c*1.8 + 32.0).long ++ " Fahrenheit")
Left _ -> JLabel.setText fahrenheitLabel ("not a valid number: " ++ celsius)
Right c -> JLabel.setText fahrenheitLabel (show (c*1.8 + 32.0).long ++ " Fahrenheit")
return ()
ActionListener.new convertButtonActionPerformed >>= convertButton.addActionListener
fahrenheitLabel.setText "Fahrenheit"
contentPane <- frame.getContentPane
layout <- GroupLayout.new contentPane
contentPane.setLayout layout
ActionListener.new convertButtonActionPerformed >>= AbstractButton.addActionListener convertButton
JLabel.setText fahrenheitLabel "Fahrenheit"
contentPane <- JPanel.new ()
-- layout <- GroupLayout.new contentPane
-- contentPane.setLayout layout
-- TODO continue
-- http://docs.oracle.com/javase/tutorial/displayCode.html?code=http://docs.oracle.com/javase/tutorial/uiswing/examples/learn/CelsiusConverterProject/src/learn/CelsiusConverterGUI.java
contentPane.add celsiusLabel
contentPane.add tempTextField
contentPane.add convertButton
contentPane.add fahrenheitLabel
contentPane.setOpaque true
frame.setContentPane contentPane
frame.pack
frame.setVisible true

Expand Down

0 comments on commit 1509c06

Please sign in to comment.