Dialogs in Applets

Discussion in 'Java' started by Roedy Green, Aug 9, 2005.

  1. Roedy Green

    Roedy Green Guest

    Roedy Green, Aug 9, 2005
    #1
    1. Advertising

  2. Roedy Green

    John Currier Guest

    Roedy Green wrote:
    > Dialogs want Frame not Panels from which Applet is derived. What did
    > Sun intend for you to do? Are you supposed to search for a parent
    > frame of Applet? create one?


    It was very common to have a getFrame() method that searched up the
    hierarchy for a Frame.

    John
    http://schemaspy.sourceforge.net
    John Currier, Aug 9, 2005
    #2
    1. Advertising

  3. Roedy Green

    Joan Guest

    "John Currier" <> wrote in message
    news:...
    > Roedy Green wrote:
    >> Dialogs want Frame not Panels from which Applet is derived.
    >> What did
    >> Sun intend for you to do? Are you supposed to search for a
    >> parent
    >> frame of Applet? create one?

    >
    > It was very common to have a getFrame() method that searched up
    > the
    > hierarchy for a Frame.
    >
    > John
    > http://schemaspy.sourceforge.net


    You can use getParent() then getClass() to find out what you got.
    Repeat as necessary.
    Joan, Aug 9, 2005
    #3
  4. On Tue, 09 Aug 2005 00:09:51 GMT, Roedy Green wrote:

    > Dialogs want Frame not Panels from which Applet is derived. What did
    > Sun intend for you to do? Are you supposed to search for a parent
    > frame of Applet? create one?


    <sscce>
    import java.awt.*;

    public class DialogApplet extends java.applet.Applet {

    public void init() {
    Frame[] frames = Frame.getFrames();
    Dialog dialog = new Dialog( frames[0] );
    dialog.add( new Label("Blah!") );
    dialog.pack();
    dialog.setVisible(true);
    }
    }
    </sscce>

    HTH

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    Scratch Here To Reveal Prize
    Andrew Thompson, Aug 9, 2005
    #4
  5. On Tue, 09 Aug 2005 05:51:13 GMT, Andrew Thompson wrote:

    > On Tue, 09 Aug 2005 00:09:51 GMT, Roedy Green wrote:
    >
    >> Dialogs want Frame not Panels from which Applet is derived. What did
    >> Sun intend for you to do? Are you supposed to search for a parent
    >> frame of Applet? create one?

    >
    > <sscce>
    > import java.awt.*;
    >
    > public class DialogApplet extends java.applet.Applet {
    >
    > public void init() {
    > Frame[] frames = Frame.getFrames();


    Which will not work for 1.1, it was introduced in 1.2 (damnit!)

    However, this seems to work[1]..

    <sscce>
    import java.awt.*;

    public class DialogApplet extends java.applet.Applet {

    public void init() {
    Dialog dialog = new Dialog( new Frame() );
    dialog.add( new Label("Blah!") );
    dialog.pack();
    dialog.setVisible(true);
    }
    }
    </sscce>

    [1] Checked in ..
    MSVM 1.1.4 (IE) and
    Symantec VM 1.1.5 (Netscape Nav. 4.78)

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    Federal Law Prohibits Changing The Channel
    Andrew Thompson, Aug 9, 2005
    #5
  6. Roedy Green

    John Currier Guest

    Joan wrote:
    > You can use getParent() then getClass() to find out what you got.
    > Repeat as necessary.


    Almost correct. You'll need to use 'instanceof Frame' instead of
    'getClass()' or you'll only find non-subclassed Frames.

    John
    http://schemaspy.sourceforge.net
    John Currier, Aug 9, 2005
    #6
  7. On 09 Aug 2005 17:30:05 +0200, Tor Iver Wilhelmsen wrote:

    > Andrew Thompson <> writes:
    >
    >> Dialog dialog = new Dialog( new Frame() );

    >
    > Will work, but will not make a "child" of the browser Frame. Which
    > means it will not hide when the browser hides, will not inherit its
    > icon etc.


    Riiight. That *could* explain the strange
    behaviour I'd noted in a Java 1.1 splash screen.

    I'll have to revisit the code to investigate further.

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    Featuring Gratuitous Alien Nudity
    Andrew Thompson, Aug 9, 2005
    #7
  8. Andrew Thompson <> writes:

    > Dialog dialog = new Dialog( new Frame() );


    Will work, but will not make a "child" of the browser Frame. Which
    means it will not hide when the browser hides, will not inherit its
    icon etc.
    Tor Iver Wilhelmsen, Aug 9, 2005
    #8
  9. Andrew Thompson <> writes:

    > I'll have to revisit the code to investigate further.


    The best way is to iterate on getParent() until you hit a Frame or
    null.
    Tor Iver Wilhelmsen, Aug 9, 2005
    #9
  10. Roedy Green

    Pete Barrett Guest

    On Tue, 09 Aug 2005 00:09:51 GMT, Roedy Green
    <> wrote:

    >Dialogs want Frame not Panels from which Applet is derived. What did
    >Sun intend for you to do? Are you supposed to search for a parent
    >frame of Applet? create one?


    If you're using Swing (and a JDialog is derived from Dialog, so is not
    a JAnythingElse) there's a SwingUtilities method to search for the
    closest parent which is an instance of a particular class (Frame, in
    this case).

    Pete Barrett
    Pete Barrett, Aug 9, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Reg Rat

    Modal dialogs

    Reg Rat, Dec 14, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    740
    Alan Pretre
    Jan 9, 2006
  2. arkam

    Share Web dialogs between apps

    arkam, Apr 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    294
    arkam
    Apr 15, 2004
  3. Ricky K. Rasmussen

    Modal dialogs causes loss of Session

    Ricky K. Rasmussen, Jul 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,165
    Ricky K. Rasmussen
    Jul 16, 2004
  4. Mark Rae

    Submission of modal dialogs

    Mark Rae, Jul 24, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    375
    Mark Rae
    Jul 25, 2004
  5. Lisa

    Printing From Modal Dialogs

    Lisa, Jan 18, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    5,024
    =?Utf-8?B?dmluYXk=?=
    Jan 18, 2005
Loading...

Share This Page