self != this ?

Below is an applet and the corresponding HTML, basically it will invoke a message box.  It works fine but in Netscape, the following message will be shown in java console:

java.awt.Dialog.__hideDialog(): self != this (self = null; this = MessageBox[dialog4,343,227,140x146,layout=java.awt.BorderLayout,modal,title=title])
result=1

Seems that it is a warning message, can anyone explain it and tell me how to avoid this message?


import java.applet.*;
import java.awt.*;
import java.awt.event.*;  


public class TestApplet extends Applet
{
      public void test()
      {
            MessageBox msg = new MessageBox("title", "hello?", "yes", "no");
            int r = msg.getResult();
            System.out.println("result="+r);
      }
}


class MessageBox extends Dialog implements ActionListener {
      Button button1;
      Button button2;
      int r = 0;
 
      public MessageBox(String title, String message, String choice1, String choice2)
      {
            super(new Frame(), title, true);
   
            setLayout(new BorderLayout(5, 5));
   
            Panel p = new Panel();
            p.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 10));
            p.add("Center", new Label (message));
            add("Center", p);
   
            p = new Panel();
            p.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 10));
            if (choice1 != null) {
                  p.add(button1 = new Button(choice1));
                  button1.addActionListener(this);
            }
            if (choice2 != null) {
                  p.add(button2 = new Button(choice2));
                  button2.addActionListener(this);
            }
            add("South", p);  

            pack();

            Dimension sz = getToolkit().getScreenSize();
            setLocation((sz.width - getBounds().width) / 2, (sz.height - getBounds().height) / 2);

            setVisible(true);
      }
                                     

      public void actionPerformed(ActionEvent event)      {
            if (event.getSource() == button1)      {
                  r = 1;
                  setVisible(false);
            } else if (event.getSource() == button2)      {
                  r = 2;
                  setVisible(false);
            }
      }

      public int getResult()
      {
            return r;
      }
}


HTML:

<HTML>
<HEAD><TITLE>Add Item</TITLE>
<SCRIPT>

function test()
{
      document.testapplet.test();
}
</SCRIPT>

</HEAD>
<BODY BACKGROUND=2.jpg>
<FORM>
<BR>
<INPUT TYPE=BUTTON VALUE="Submit" onClick="test()">

</FORM></CENTER>
<APPLET CODE="TestApplet.class" NAME="testapplet" WIDTH=0 HEIGHT=0>
</APPLET>

<!--START OF FOOTER-->
<HR>
</BODY></HTML>
LVL 7
fasterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vladi21Commented:
try make r static :)
0
fasterAuthor Commented:
it does not matter
0
vladi21Commented:
Its just trace :)

from Netscape\Communicator\Program\Java\Classes\java40.jar

// Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3)
// Source File Name:   Dialog.java

package java.awt;

import java.awt.peer.ComponentPeer;
import java.awt.peer.DialogPeer;
import java.io.PrintStream;
import java.util.Enumeration;
import java.util.Vector;
import sun.awt.SunToolkit;

// Referenced classes of package java.awt:
//            Window, Frame, Container, Toolkit,
//            Dimension, Component

public class Dialog extends Window
{

    public Dialog(Frame frame)
    {
        this(frame, "", false);
    }

    public Dialog(Frame frame, boolean flag)
    {
        this(frame, "", flag);
    }

    public Dialog(Frame frame, String s)
    {
        this(frame, s, false);
    }

    public Dialog(Frame frame, String s, boolean flag)
    {
        super(frame);
        resizable = true;
        if(frame == null)
        {
            throw new IllegalArgumentException("null parent frame");
        }
        else
        {
            name = "dialog" + nameCounter++;
            title = s;
            modal = flag;
            return;
        }
    }

    public void addNotify()
    {
        if(peer == null)
            peer = getToolkit().createDialog(this);
        super.addNotify();
    }

    public boolean isModal()
    {
        return modal;
    }

    public void setModal(boolean flag)
    {
        modal = flag;
    }

    public String getTitle()
    {
        return title;
    }

    public synchronized void setTitle(String s)
    {
        title = s;
        DialogPeer dialogpeer = (DialogPeer)peer;
        if(dialogpeer != null)
            dialogpeer.setTitle(s);
    }

    public void show()
    {
        super.show();
    }

    protected void __showDialog()
    {
        synchronized(Component.LOCK)
        {
            if(parent != null && parent.getPeer() == null)
                parent.addNotify();
            if(peer == null)
            {
                addNotify();
                Dimension dimension = getMinimumSize();
                if(dimension.width > width || dimension.height > height)
                    setSize(dimension);
            }
            validate();
        }
        if(visible)
        {
            toFront();
            return;
        }
        visible = true;
        if(isModal())
        {
            Window awindow[] = SunToolkit.getTopLevelWindows();
            if(awindow == null)
            {
                Frame frame = (Frame)getParent();
                int j = frame.ownedWindows.size() + 1;
                awindow = new Window[j];
                frame.ownedWindows.copyInto(awindow);
                awindow[j - 1] = frame;
            }
            m_disabledWindows = new Vector(awindow.length);
            for(int i = 0; i < awindow.length; i++)
            {
                Window window = awindow[i];
                if(window != this && window.isVisible() && window.isEnabled())
                {
                    m_disabledWindows.addElement(window);
                    window.enabled = false;
                    window.getPeer().setEnabled(false);
                }
            }

            m_previousModalDialog = SunToolkit.swapTopModalDialog(this);
        }
        peer.show();
    }

    void __hideDialog()
    {
        if(!visible)
            return;
        if(isModal())
        {
            if(m_disabledWindows == null)
                return;
            Dialog dialog = SunToolkit.swapTopModalDialog(m_previousModalDialog);
            if(dialog != this)
                System.out.println("java.awt.Dialog.__hideDialog(): self != this (self = " + dialog + "; this = " + this + ")");
            if(m_previousModalDialog != null)
                m_previousModalDialog.toFront();
            Window window;
            for(Enumeration enumeration = m_disabledWindows.elements(); enumeration.hasMoreElements(); window.getPeer().setEnabled(true))
            {
                window = (Window)enumeration.nextElement();
                window.enabled = true;
            }

        }
    }

    public boolean isResizable()
    {
        return resizable;
    }

    public synchronized void setResizable(boolean flag)
    {
        resizable = flag;
        DialogPeer dialogpeer = (DialogPeer)peer;
        if(dialogpeer != null)
            dialogpeer.setResizable(flag);
    }

    protected String paramString()
    {
        String s = super.paramString() + (modal ? ",modal" : ",modeless");
        if(title != null)
            s = s + ",title=" + title;
        return s;
    }

    boolean resizable;
    boolean modal;
    String title;
    private static final String base = "dialog";
    private static int nameCounter;
    private static final long serialVersionUID = 0x522b5ba60a3fb00dL;
    private Vector m_disabledWindows;
    private Dialog m_previousModalDialog;
}


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
fasterAuthor Commented:
According to the source, it seems that it will complain when the dialog box to be closed is not the top one.  Do you have any better idea?

Thanks.

0
vladi21Commented:
yes something like this
and i think i release version of product all trace must be removed :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.