| Author |
Can JFrame be added to a container?
|
Igor Mechnikov
Ranch Hand
Joined: Feb 13, 2011
Posts: 100
|
|
Please explain.
Thank you.
|
String knock = "\u042F \u0418\u0433\u043e\u0440\u044c";
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3791
|
|
|
Have you tried it? What happens?
|
 |
Igor Mechnikov
Ranch Hand
Joined: Feb 13, 2011
Posts: 100
|
|
Matthew Brown wrote:Have you tried it? What happens?
Have not tried.
Just wanted to verify an answer from a self-quiz.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
Go through the documentation for Container and see what parameters its add methods take.
And I shall move you to our GUIs forum.
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3791
|
|
Ilya Mechnikov wrote:Have not tried.
Just wanted to verify an answer from a self-quiz.
Well, the easiest, and most reliable, way to verify it is to try it. Try compiling and running the following, see what happens:
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
|
So, I went into the API and could find nothing in add() which explained that behaviour. There was a link in add() to something else which does explain that behaviour, but I think the documentation could be improved a bit there.
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
I think the documentation could be improved
I agree. I also feel it's counter-intuitive that the last component added goes to the bottom, and not the top, of the stacking order.
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Igor Mechnikov
Ranch Hand
Joined: Feb 13, 2011
Posts: 100
|
|
Matthew Brown wrote:
Ilya Mechnikov wrote:Have not tried.
Just wanted to verify an answer from a self-quiz.
Well, the easiest, and most reliable, way to verify it is to try it. Try compiling and running the following, see what happens:
Thank you much.
I look forward to being able to produce code snippets for testing purposes, until then I must rely on the kindness of strangers.
The code compiled but had runtime errors:
run JFrameInAContainerTest
java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.addImpl(Container.java:1061)
at java.awt.Container.add(Container.java:377)
at JFrameInAContainerTest.main(JFrameInAContainerTest.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at edu.rice.cs.drjava.model.compiler.JavacCompiler.runCommand(JavacCompiler.java:271)
Thank you again!
|
 |
budsy remo
Ranch Hand
Joined: Sep 20, 2008
Posts: 103
|
|
|
what is the explanation to this?
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32654
|
|
|
Have you read my earlier post?
|
 |
 |
|
|
subject: Can JFrame be added to a container?
|
|
|