CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    4

    Can a messagebox be popped up from an applet's stop() method?

    Hi, everyone,

    I want to show a messagebox before browser changed to other page. Is applet's stop() method a good place? Can I show messagebox in stop() method? I tried, in AppletViewer, it's OK, but not in IE and netscape. Can anyone do me a favor to give me some suggestions?

    Thanks.

    Sunny


    Sunny Cheng

  2. #2
    Join Date
    Oct 2000
    Posts
    11

    Re: Can a messagebox be popped up from an applet's stop() method?

    Hi Sunny,

    When user leaves current page, browser will destroy the Applet. Thus, even you pop up a message dialog in stop(), user may not see it because restroy() is called after stop(). Try to use JavaScript to display a message dialog instead of Java Applet.

    HTH

    Lynx


  3. #3
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: Can a messagebox be popped up from an applet's stop() method?

    I had tried to show dialog box in stop method, and it was working when I ran that applet in browser.

    I used JRE1.2 that time. And dialog box was confirmation dialog in JOptionPane.

    - UnicMan
    http://members.tripod.com/unicman

  4. #4
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: Can a messagebox be popped up from an applet's stop() method?

    I had tried to show dialog box in stop method, and it was working when I ran that applet in browser.

    I used JRE1.2 that time. And dialog box was confirmation dialog in JOptionPane.

    You can try that if you haven't tried already.

    btw I had observed that 'stop' method is called even if applet is minimized (i.e. browser window). I don't know if it happens for normal window... I used to open new window for applet in my software.

    - UnicMan
    http://members.tripod.com/unicman

  5. #5
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    4

    Re: Can a messagebox be popped up from an applet's stop() method?

    Yes, I'm using confirmation dialog of JOptionPane, jre1.2, IE and Netscape, neither could show it. Only AppletViewer could.
    By the way, what is the first param for JOptionPane? null? this? this.parent()? or new Frame()? Only the last one I didn't try yet, all others weren't work.

    Thanks.

    Sunny.

    Sunny Cheng

  6. #6
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    4

    Re: Can a messagebox be popped up from an applet's stop() method?

    Hi, Lynx,

    I checked the jave doc, it said that before the stop() was called, the old page HAS BEEN destroied. But I wonder if the parent HAS BEEN destroied, could the children still exist? If it couldn't, stop() should be called BEFORE destroying the embeded page. And, the dialog is a modal frame in the same thread, system should wait for the user clicking then call destory(). So, I think that the dialog should be shown.

    I don't want to use JavaScript, if I can find a way to do this. The applet is a information collector. I want to give users a chance to send their input to server before losing it.

    Thanks



    Sunny Cheng

  7. #7
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: Can a messagebox be popped up from an applet's stop() method?

    I tried with null as parent, its working in stop and destroy method.

    - UnicMan
    http://members.tripod.com/unicman

  8. #8
    Join Date
    Oct 2000
    Location
    Canada
    Posts
    4

    Re: Can a messagebox be popped up from an applet's stop() method?

    Thank you.

    I tried null, but It didn't work at my system. So,
    I tried new JFrame(), new JWindow() as the parent.
    the JWindow worked fine for me.

    Thank you for your help.


    Sunny Cheng

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured