This is really a Java question, not a Jess question, but...

To paraphrase the error message, 

  Message: Constructor threw an exception.
Nested exception is:
null
java.lang.NullPointerException
        at jess.examples.pumps.Pump.addPropertyChangeListener(Pump.java:67)
        at javax.swing.plaf.basic.BasicLabelUI.installListeners(BasicLabelUI.java:306)
        ...
        at javax.swing.JLabel.<init>(JLabel.java:141)

i.e., JLabel calls addPropertyChangeListener() from its constructor,
not realizing that it's being called from a subclass. Pump has
overridden this method.  At the time this base class constructor runs,
Pump hasn't constructed its PropertyChangeSupport member object yet,
so there is an error.

The fix is fairly obvious: you have to write your base classes to use
the parent's existing property change support mechanism. This is
simple: there are of course public addPropertyChangeListener methods,
and also there are firePropertyChange methods. Change the subclass to
call the inherited firePropertyChange methods instead of forwarding
them to a contained PropertyChangeSupport object, and simply remove
the addPropertyChangeListener/removePropertyChangeListener methods.

I think =?ISO-8859-1?B?Suly9G1lIExlaHVlbg==?= wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 
> Hi,
> 
> I develop a reactive graphical interface.
> The graphical objects are derivated from JLabel
> and have a PropertyChangeSupport to be manipulated
> directly from Jess.
> 
> this is my problem : there is conflict with the
> JLabel's PropertyChangeSupport. To observe the error,
> you can modify the Pump & Tank demo like this :
> 
> public class Pump extends JLabel implements Runnable, Serializable
> {
> ...
> }
> 
> Can you help me ?

---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to