public class X extends Applet implements ItemListener{
A a;
Choice ch;
Panel master;
public void init(){
a = new A( int);
master = new Panel();
ch = new Choice();
ch.add( "stuff");
ch.addItemListener( this);
master.add( a);
this.add( master);
this.add( ch);
}
public void itemStateChanged( ItemEvent e){
a = new A( ch.getSelectedIndex());
}
}
class A extends Panel{
public C [] aCanvas;
public A( int ){
for( int i=0; etc;;){
aCanvas[i] = new C( int);
add( aCanvas[i]);
}
}
class C extends Canvas{
public C( int){
setSize();
etc;
}
public void paint(){
draw stuff;
this doesn't get called
after itemStateChanged
creates the new A, though
the C constructor does.
I thought it would be,
because it gets called when
the applet starts up.
}
}
It is far more complicated than you would ever imagine.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.