Developing Java Beans by Robert Englander Here are the changes made in the 11/99 reprint: {xvi} Changed email from: rob.englander@worldnet.att.net To: rob@mindstrm.com {26} Changed is the base class for all components to: is the base class for many components {31} Changed setLabel(new Integer(count).toString)); to: setLabel(String.valueOf(count)); {32} Changed this(``"); to: this(""); {34} Changed protected void temperature2Changed(double newTemp); to: protected void temperature2Changed(double newTemp) {34} Changed if (thermometer1 == evt.getSource()) to: if (temperature1 == evt.getSource()) {35} Changed if (thermometer2 == evt.getSource()) to: if (temperature2 == evt.getSource()) {36} In the code, line 2: changed "implements TemperatureChangeListener" to "implements TempChangeListener" {38} The invocation of super() referenced a class variable too early. Changed TemperatureAdapter1() { super(theTemperature1); } to: TemperatureAdapter1(Temperature t) { super(t); } {38} Changed TemperatureAdapter2() { super(theTemperature2); } to: TemperatureAdapter2(Temperature t) { super(t); } {39} Changed (double newTemp); to (double newTemp) {43} Changed that adapts the TempChangedListener to: that adapts the TempChangeListener {45} The method calls must account for the NoSuchMethodException. Changed tempAdapter.registerEventHandler(theTemperature1, "temperature1Changed"); tempAdapter.registerEventHandler(theTemperature2, "temperature2Changed"); to: try { tempAdapter.registerEventHandler(theTemperature1, "temperature1Changed"); tempAdapter.registerEventHandler(theTemperature2, "temperature2Changed"); } catch (NoSuchMethodException e) { System.out.println(e); } {46} Changed protected void temperature1Changed to: public void temperature1Changed also changed: protected void temperature2Changed to: public void temperature2Changed {47} This constructor may throw a ClassNotFoundException. Changed public GenericButtonAdapter(Object target) to public GenericButtonAdapter(Object target) throws ClassNotFoundException {49} Changed (in all three places) Button b = e.getSource(); to: Button b = (Button)e.getSource(); also changed: public void handleB3(MouseEvent e) to: public void handleB#(ActionEvent e) {51} Changed evt.getTemperature() > highTemperature) to: evt.getTemperature() > highThreshold) {56} Changed public void pollSent(PollEvent e) to: public synchronized void pollSent(PollEvent e) also changed this.resume(); to: this.notify(); {57-58} Changed this.suspend(); to: try { this.wait(); } catch (Exception e) { } {61} Changed theTemperature. addTempChangeListener(this); to: theTemperature.addTempChangeListener(this); {68} Changed PropertyChangedEvent evt = to: PropertyChangeEvent evt = also changed new PropertyChangedEvent to: new PropertyChangeEvent {75} Changed "constrainedhandler" to "constrainedHandler" {76} Changed our own criteria to: our own criterion {76} Changed "constrainedhandler" to "constrainedHandler" {76} Changed throw new PropertyVetoException(); to: PropertyChangeEvent e = new PropertyChangeEvent(this, "MinimumTemperature", null, new Double(newVal)); throw new PropertyVetoException("Bad MinimumTemperature", e); {113} Changed (2 places): "s.writeObject" to "stream.writeObject"; also, changed "s.readObject" to "stream.readObject" {134} Changed 2 occurences of ARCHIVES to: ARCHIVE {145} Changed Beans.util.PickleButton to: BeansBook.util.PickleButton {153} Changed java.io.PropertyChangeEvent to: java.beans.PropertyChangeEvent {153} Changed simulator tend to be to: simulator tends to be {160} Changed // boolean bWriteNull to: boolean bWriteNull {168} Add to the import list: import java.io.*; {168} Changed and ambientTemperature to: and ambientTemp {174} Changed setNeedsCooling((ambientTemp > comfortTemp) && (ambientTemp - comfortTemp >= 1.0)); setNeedsHeating((ambientTemp < comfortTemp) && (comfortTemp - ambientTemp >= 1.0)); to: setNeedsCooling(ambientTemp - comfortTemp >= 1.0); setNeedsHeating(comfortTemp - ambientTemp >= 1.0); {175} Changed new Integer(d.longValue to: new Long(d.longValue {181} Changed setNeedsCooling((ambientTemp > comfortTemp) && (ambientTemp - comfortTemp >= 1.0)); setNeedsHeating((ambientTemp < comfortTemp) && (comfortTemp - ambientTemp >= 1.0)); to: setNeedsCooling(ambientTemp - comfortTemp >= 1.0); setNeedsHeating(comfortTemp - ambientTemp >= 1.0); {182} Changed (2 places): "s.writeObject" to "stream.writeObject"; also changed "if (heatingListeners!= null)" to "if (heatingListeners != null)" {183} Changed (2 places): "s.writeObject" to "stream.writeObject"; also changed "s.readObject" to "stream.readObject" {258} Changed temperaturePulse(new TemperaturePulseEvent(null, pulse)); to: temperaturePulse(new TemperaturePulseEvent(this, pulse)); {258} Removed the sentence I've passed null as the first parameter to the constructor, indicating that the actual source of the pulse is unknown. {299} "About the Author", para. 1 now reads as follows: Rob Englander is the President and Principal Engineer at MindStream Software, Inc., a firm specializing in custom software development in Java and C++ for a wide range of application areas.