在JDK1.1中Thread类定义了suspend()和resume()方法,但是在JDK1.2中已经过时,应使用什么方法来替代之?

来源:百度知道 编辑:UC知道 时间:2024/05/31 14:33:44

在Java applet中实现模式对话框的关键就是在创建一个对话框的时候 要为该对话框指定一个正确的父窗口.因为Applet是Panel类的子类,不 可以作为对话框的父窗口,所以首先要获得applet所在的窗口,作为模式 对话框的父窗口. 样例代码如下:

.....
Dialog d = new Dialog( getParentWindow(comp),title);

// comp为applet上的任意一个组件

....

public void getParentWindow(Component compOnApplet,String title){

Container c = compOnApplet.getParent();

while (c != null) {

if (c instanceof Frame)

return (Frame) c;

c = c.getParent();

}

return null;

}