Applet calls to JDialog and JPanel

J

javaseeker

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?
 
T

Thomas Weidenfeller

javaseeker said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top