Override a function without extending the class
<p>Suppose I have a class A:</p>

<pre><code>public class A {
    public A(){....}
    public void method1() {...}
};
</code></pre>

<p>And an instance of that class:</p>

<pre><code>A anA = new A();
</code></pre>

<p>Is there any way to override the <code>method1()</code> only for <code>anA</code>?
This question arises when I write a small painting program in which I have to extend the <code>JPanel</code> class several times just to make minor changes to the different panels that have slightly different characteristics.</p>
