![]()
(chat, newsreader, calendar)
|
![]() |
|
|
|
Course Notes Table of Contents Exercises | Online Training Index
|
|
From Kiva Han to Central Perk
MageLang Institute
|
[Help | Solution |
API Docs |
Behavior |
Course Notes |
Exercises]
PrerequisitesSkeleton CodeIn 1994, NBC's Friends started hanging out in Central Perk. It is meant to represent the upscale coffeehouses of today. This exercise builds upon the basic KivaHan bean, from the Kaidi exercise, into the sophisticated CentralPerk bean. Instead of being a non-scrolling billboard like Kaidi, CentralPerk is a customizable scrolling bean, with perking events and constrained properties. The skeleton for CentralPerk provides a scrolling billboard, you get to add the parts that make it a Bean.
Perform the following tasks:
In order to make our properties bound, we need to maintain a PropertyChangeSupport list and add/remove listeners to it. Also, the property set routines need to be modified to fire property changes to the listeners when the changes happen. Be sure to update both setMessage and setMovingRate. Whenever a message starts scrolling in from the right, we want to generate a PerkEvent. In order for this to happen, we need to define the event, and give it a read-only message property. Next, we need to create a PerkListener and give it a method for us to call when the PerkEvent happens. Lets call it startedPerking. Back in CentralPerk, we need to maintain a PerkListener list and add/remove listeners to it. Also, when the event happens, we need to notify the listeners. Finally, we need to check if everything is Serializable. Flag anything that isn't as transient Because of the nature of our transient variable, we need to override the default serialization reading routine readObject to initialize the variable. The writing routine writeObject doesn't have to do anything special, but because of the requirements of serialization is required to be present. Add a readObject and writeObject routine to CentralPerk. Okay, now that we've finished our Bean, we can try it out. Use the CentralPerkTester applet and loader to try it out.
|
|
Copyright © 1997 MageLang Institute. All Rights Reserved May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved |