Applet calls to JDialog and JPanel

Discussion in 'Java' started by javaseeker, Jun 14, 2004.

  1. javaseeker

    javaseeker Guest

    I was just checking out a few calls to different Applets using
    reflection.
    I could manage a call to Classes which extends JPanel but i couldnt
    manage to call Classes which extend JDialog(the parent window
    extending JPanel) .The call is as follows.

    Class c = Class.forName(className) ; // Got the class name by
    reflection
    DialogInterface dialog = (DialogInterface)c.newInstance(); //
    Implementing Dialog interface
    dialog.setProperties (props) ; // Let them know the properties
    in the session
    dialog.setCallback (this) ; // How they get back to us after
    operation in new screen
    getSplitPane().add((java.awt.Component)dialog, "right") ; // Add the
    panel to the right hand pane using split pane
    dialog.init (); // Let the panel do it's stuff

    The error that comes up is :
    java.lang.IllegalArgumentException: adding a window to a container.

    Hope have given the problem statement properly(any extra info needed)

    Maybe my concepts may not be clear.Any ides where i went wrong?
    javaseeker, Jun 14, 2004
    #1
    1. Advertising

  2. javaseeker wrote:
    > I was just checking out a few calls to different Applets using
    > reflection.
    > I could manage a call to Classes which extends JPanel but i couldnt
    > manage to call Classes which extend JDialog(the parent window
    > extending JPanel) .The call is as follows.

    [...]
    > The error that comes up is :
    > java.lang.IllegalArgumentException: adding a window to a container.
    >
    > Hope have given the problem statement properly(any extra info needed)
    >
    > Maybe my concepts may not be clear.Any ides where i went wrong?


    a) There is a separate newsgroup for GUI questions: comp.lang.java.gui

    b) Why do you use reflection to instantiate these GUI components?

    c) Are you really using Applet, not JApplet?

    d) The exception is absolutely clear. JDialog is not a subclass of
    Component, it is a subclass of Window. It is a top-level window and as
    such doesn't belong in a Container. Read the API documentation. Read
    Sun's GUI tutorial.

    e) Since you didn't spent a single word on why you are doing this, I can
    only guess that you might want JInternalFrame with a JDesktopPane
    instead. Or you might not.

    /Thomas
    Thomas Weidenfeller, Jun 14, 2004
    #2
    1. Advertising

  3. On 13 Jun 2004 22:32:55 -0700, javaseeker wrote:

    > ..Hope have given the problem statement properly(any extra info needed)


    Try an SSCCE, note carefully what
    it says re line length..
    <http://www.physci.org/codes/sscce.jsp>

    Also see.
    <http://www.physci.org/codes/javafaq.jsp#exact>

    HTH

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
    Andrew Thompson, Jun 14, 2004
    #3
    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. Andreas Beresko

    Add a JPanel to a JPanel...

    Andreas Beresko, Jul 14, 2004, in forum: Java
    Replies:
    6
    Views:
    26,955
  2. FutureScalper
    Replies:
    3
    Views:
    1,001
    FutureScalper
    Jan 21, 2008
  3. Raphael Jolivet

    [JPanel] Drop Down JPanel

    Raphael Jolivet, Jul 18, 2008, in forum: Java
    Replies:
    1
    Views:
    1,503
    John B. Matthews
    Jul 18, 2008
  4. etantonio
    Replies:
    1
    Views:
    727
    Andrew Thompson
    Apr 19, 2009
  5. t1m1976
    Replies:
    1
    Views:
    2,386
    t1m1976
    Nov 7, 2010
Loading...

Share This Page