Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

Chapter 34: GUI Programming > 34.5 Conclusion - Pg. 767

S ECTION 34.5 · Conclusion one after another, in one or more rows, depending on the width of the frame. The reactions of TempConverter are defined by a handler that con- tains two cases. Each case matches an EditDone event for one of the two text fields. Such an event gets issued when a text field has been edited by the user. Note the form of the patterns, which include back ticks around the element names: case EditDone(`celsius`) As was explained in Section 15.2, the back ticks around celsius ensure that the pattern matches only if the source of the event was the celsius object. If you had omitted the back ticks and just written case EditDone(celsius) , the pattern would have matched every event of class EditDone . The changed field would then be stored in the pattern variable celsius . Obviously, this is not what you want. Alternatively, you could have defined the two TextField objects starting with upper case characters, i.e., Celsius and Fahrenheit . In that case you could have matched them directly without back ticks, as in case EditDone(Celsius) . The two actions of the EditDone events convert one quantity to another. Each starts by reading out the contents of the modified field and converting it