faster
asked on
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.__hideDial og(): self != this (self = null; this = MessageBox[dialog4,343,227 ,140x146,l ayout=java .awt.Borde rLayout,mo dal,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.CENT ER, 20, 10));
p.add("Center", new Label (message));
add("Center", p);
p = new Panel();
p.setLayout(new FlowLayout(FlowLayout.CENT ER, 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(ActionEven t 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>
java.awt.Dialog.__hideDial
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
}
}
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.CENT
p.add("Center", new Label (message));
add("Center", p);
p = new Panel();
p.setLayout(new FlowLayout(FlowLayout.CENT
if (choice1 != null) {
p.add(button1 = new Button(choice1));
button1.addActionListener(
}
if (choice2 != null) {
p.add(button2 = new Button(choice2));
button2.addActionListener(
}
add("South", p);
pack();
Dimension sz = getToolkit().getScreenSize
setLocation((sz.width - getBounds().width) / 2, (sz.height - getBounds().height) / 2);
setVisible(true);
}
public void actionPerformed(ActionEven
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>
try make r static :)
ASKER
it does not matter
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
Thanks.
yes something like this
and i think i release version of product all trace must be removed :)
and i think i release version of product all trace must be removed :)