Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

when is canvas paint() called?

0 views
Skip to first unread message

gerr...@indigo.ie

unread,
Jul 22, 2003, 2:25:18 PM7/22/03
to
I've got an applet which draws a set of pictures,
When the applet starts up it draws them fine, but when I
make a selection from the choice box, the new set is not
painted. Rather than post several hundred lines of code, I hope
the following makes enough sense to find where I'm going wrong.
If there's not enough here I could email the full code to
anyone who could help, I'm sure there's an easy fix if only
one knows how.
Thanks very much for any help,
Gerard

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.
}
}

Roedy Green

unread,
Jul 22, 2003, 2:50:16 PM7/22/03
to
On Tue, 22 Jul 2003 18:25:18 GMT, gerr...@indigo.ie wrote or quoted :
To understand how painting works see
http://mindprod.com/jgloss/image.html
and also http://mindprod.com/jgloss/repaint.html
and http://mindprod.com/jgloss/paint.html

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.

0 new messages