[thelist] Java classes and events

David Treves dwork at macam.ac.il
Sun Jan 12 00:26:01 CST 2003


Hi Kevin,

The idea of the Observable class is that this is the basic class which you
need to extend in order to enjoy it's facilities.

Apparently your needs are different since you have a panel which MUST extend
Panel/JPanel, and as you know Java supports Single-Inheritance. Therefore
you cannot extend Observable as well.

In your case I would simply pass a reference of the container to the inner
panel (via the constructor or a setter method of the inner panel), and refer
to the container anytime I wish from within that panel.

I hope I was clear...  :o)
David.

----- Original Message -----
From: "Kevin W" <null at tsn.cc>
To: <thelist at lists.evolt.org>
Sent: Friday, January 10, 2003 3:23 AM
Subject: Re: [thelist] Java classes and events


> On Thursday, David Treves wrote:
> > Use Observer/Observable design. You may read about it in JavaDocs. The
> > basic idea is that one object is the observable and it notifies all
> > observers when some event occurs.
>
> OK, Thanks.  I have one question.
>
> Do I make the Observable a subclass of my Board class (which is a subclass
> of JPanel)?  If so, then I just have to move my Board constructor to the
> Observable class and refer to the Observable class instead of Board, yes?
>
> --
> Kevin W :-)
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !




More information about the thelist mailing list