Override an overridden method
<p>Class A Method M1 version1</p>

<p>Class B extends A Overrides Method M1 version2</p>

<p>Now I want a slightly changed version of class B (what I want to change is M1 behaviour, bear in mind that B has a lot of other methods)</p>

<p>If I define an new instance of  class B and override M1 in its definition:</p>

<pre><code> B temp = new B {@Override M1 version3 }
</code></pre>

<p>What I'm getting is that M1 v3 AND v2 are being called</p>

<p>How could I avoid v2?</p>

<p>Edit: Didn't notice that text format was lost plus there's a typo in the above question. Ok here's the code:</p>

<p>This is the class extending:</p>

<pre><code>public static class dialogCloseButton extends DialogBox{
    public dialogCloseButton(boolean autoHide, boolean modal)
      {
        super(autoHide, modal); .....

      }

    @Override 
    protected void onPreviewNativeEvent(NativePreviewEvent event)
    {
        NativeEvent nativeEvent = event.getNativeEvent();

        if (!event.isCanceled()
                &amp;&amp; (event.getTypeInt() == Event.ONCLICK)
                &amp;&amp; isCloseEvent(nativeEvent))
        {           
            this.hide();
        }
        if (!event.isCanceled()
                &amp;&amp; (event.getTypeInt() == Event.ONCLICK)
                &amp;&amp; isCenterEvent(nativeEvent))
        {
            this.center();
        }           
        super.onPreviewNativeEvent(event);
      }

      ......

}
</code></pre>

<p>And this is an instance of B trying to change onPreviewNativeEvent behaviour (panel is contained within dialGestCesion) :</p>

<pre><code>        dialogCloseButton dialGestCesion = new dialogCloseButton(false,true){
            @Override
            protected void onPreviewNativeEvent(NativePreviewEvent event)
            {
                NativeEvent nativeEvent = event.getNativeEvent();

                if (!event.isCanceled()
                        &amp;&amp; (event.getTypeInt() == Event.ONCLICK)
                        &amp;&amp; isCloseEvent(nativeEvent))
                {           
                    panel.checkStuffAndCloseOnlyIfOk(); /*Just this changed*/
                }
                if (!event.isCanceled()
                        &amp;&amp; (event.getTypeInt() == Event.ONCLICK)
                        &amp;&amp; isCenterEvent(nativeEvent))
                {
                    this.center();
                }           
                super.onPreviewNativeEvent(event);
              }                     
        };
</code></pre>

<p>Right now onPreviewNativeEvent is getting fired with both versions (code block 1 and 2)</p>
