Hi, I have a problem that i can't find mentioned in the archives here.
I have a JApplet that gets switched around between states and when the
states change I want to show different controls. I can
getContentPane().remove() the controls i don't want and then repaint()
and that works great. But when I getContentPane().add(newControl, 0)
(the 0 is to put it on top) then *sometimes* it shows and sometimes
not, differently across launches even. I can sometimes resize the
applet to make the stuff show, and then it does, but only after a lot
of jiggling the resize box. Different types of controls seem to work
different ways, for example I have a JSplitPane that doesn't show up
without jiggling, but if i put it in a JPanel first it shows up right
away.
It's not a threading issue, I do the work on a click.
Anyone ever heard of this?? Thanks.
Roedy Green - 12 Oct 2005 02:42 GMT
> getContentPane().add(newControl, 0)
after an add, you need a validate.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
daniel.w.gelder@gmail.com - 12 Oct 2005 09:10 GMT
Calling validate() on the applet did the trick real nice. Thank you so
much. I had never heard of that command and don't see it in my java
book.
Andrew Thompson - 12 Oct 2005 09:40 GMT
> Calling validate() on the applet did the trick real nice. ...
> I had never heard of that command ..
Aaah.. that is where the JavaDocs become very handy.
The downloadable version is much better, but they
can also be browsed online. Here is the 'Overview'
page of the JavaDocs.
<http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html>
(click the link to the 'frames' version if you feel
brave and have very 'broad'band - they are huge!)
Note that if you 'search' down through the methods
of the Docs for JApplet*, you will see 'validate'.
<http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JApplet.html>
> ..don't see it in my java book.
Books are great (try reading the JavaDocs on a train,
or at the bus stop!), but they can only take you so
far. Time to *bookmark* the JavaDocs, no?
Roedy Green - 13 Oct 2005 05:33 GMT
>Calling validate() on the applet did the trick real nice. Thank you so
>much. I had never heard of that command and don't see it in my java
>book.
see http://mindprod.com/jgloss/validate.html
http://mindprod.com/jgloss/pack.html
http://mindprod.com/jgloss/layout.html
It is an absolutely crucial step, like setVisible

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Thomas Weidenfeller - 12 Oct 2005 08:37 GMT
> Hi, I have a problem that i can't find mentioned in the archives here.
Oh, it is for sure there.
> I have a JApplet that gets switched around between states and when the
> states change I want to show different controls.
"Controls" is Windows slang. Commonly these things are called widgets,
and in Java they are also called components.
Regarding your problem: You want a CardLayout.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/