JOptionPane也可以在applet中显示的啊?有什么问题吗?

解决方案 »

  1.   

    这就是一个警告框,需要的时候调用它就是,不过创建class时要implements 
    ActionListener
    Button butt_ok = new Button("   ok   ");
    Dialog dlgConnect = new Dialog(this, "警告信息", true);
    public void _actionNOte(String note){
            dlgConnect.setSize(260, 120);
            dlgConnect.setLocation((this.getBounds().x + this.getBounds().width / 2) - 150,
                                (this.getBounds().y + this.getBounds().height / 2) - 150);
            dlgConnect.addWindowListener(new WindowAdapter()
            {
               public void windowClosing(WindowEvent _we)
               {
                   _we.getWindow().dispose();
                   dlgConnect.removeAll();
                   System.gc();
               }
            });
            //Label lblUName = new Label(note);
            Label lblUName = new Label(note);
            butt_ok.addActionListener(this);
            butt_ok.setActionCommand("10");
            dlgConnect.setLayout(new GridLayout(2, 1, 1, 2));
            Panel panel2 = new Panel();
            Panel panel3 = new Panel();
            panel2.add(lblUName);
            panel3.add(butt_ok);
            dlgConnect.add(panel2);
            dlgConnect.add(panel3);
            dlgConnect.setVisible(true);
    }
      

  2.   

    谢谢,这段程序如果在frame里面用当然好用,不过在applet中创建一个按钮,然后调用对话框,不行的,因为Dialog并没有对应applet的构造程序!
      

  3.   

    呵呵,你可以使用swing,不过前提是你的浏览器要装java-plugin
    可以参考:http://java.sun.com/products/plugin/
      

  4.   

    你可以再applet中去调用frame呀,我就是这样干的。我这个就是再applet中用的。