example try:
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet; public class test extends Applet implements ActionListener {
Button b; private Frame findParentFrame(){
Container c = this;
while(c != null){
if (c instanceof Frame)
return (Frame)c; c = c.getParent();
}
return (Frame)null;
} public void init(){
setLayout(new FlowLayout());
b = new Button("push me");
b.addActionListener(this);
add(b);
} public void actionPerformed(ActionEvent e){
Frame f = findParentFrame();
if(f != null){
Dialog d = new Dialog(f, "modalDialog", true);
d.setLayout(new FlowLayout());
d.add(new Label("hello"));
d.pack();
d.setLocation(100,100);
d.show();
}
}
}
import java.awt.*;
import java.awt.event.*;
import java.applet.Applet; public class test extends Applet implements ActionListener {
Button b; private Frame findParentFrame(){
Container c = this;
while(c != null){
if (c instanceof Frame)
return (Frame)c; c = c.getParent();
}
return (Frame)null;
} public void init(){
setLayout(new FlowLayout());
b = new Button("push me");
b.addActionListener(this);
add(b);
} public void actionPerformed(ActionEvent e){
Frame f = findParentFrame();
if(f != null){
Dialog d = new Dialog(f, "modalDialog", true);
d.setLayout(new FlowLayout());
d.add(new Label("hello"));
d.pack();
d.setLocation(100,100);
d.show();
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货