在applet中,不能FileDialog d=new FileDialog(frame,"FileDialog");
因为没有Frame!!!!但是我想实现openfiledialog和savefiledialog 。
高手快回答啊

解决方案 »

  1.   

    自己做的类extends Frame
    然后showWindow(true)...
      

  2.   

    applet里也有Frame的,从你的applet类开始向上找parent(用getParent方法)就可以了。
      

  3.   

    看看这个:问: 
    在Java applet中如何实现一个模式对话框? 答: 
    在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;} 
      

  4.   

    我照着做,还是不行。
    源码:
      void button4_mouseClicked(MouseEvent e) {
        Dialog d;
        Container c = panel1.getParent();
        while (c != null) {
          if (c instanceof Frame)
            break;
            c = c.getParent();
        }
        if(c !=null)
           d = new Dialog( (Frame) c,"fdf");
        else
           System.out.println( "c is null \n");  }结果只得:c is null           :(
      

  5.   

    Container c = panel1.getParent();
    改成Container c=button4.getParent();试一试,
    你是在ie里试的吗,appletviewer可能不一样