>From: Garth Allen Dickie <###@###.###>
This does not look like form output to me.
Hi, I am using JDK beta 2 and Netscape 2.0 beta 5 running
on a Solaris 2.4 machine. Running my Java applet under both
appletviewer and Netscape, I find the following cosmetic bug:
If a container is already visible and I add a new component,
then the new component is drawn twice. The new component
appears first in a default positition (its layout method
has not been called?), and then again in the correct position.
You can observe the problem at the URL
http://www.win.tue.nl/win/math/dw/personalpages/dickie/layouttest.html
The source code for the demo applet is as follows:
import java.applet.Applet;
import java.awt.*;
public class LayoutTestApplet extends Applet {
final static int count = 8;
final static int height[ ] = { 4, 3, 7, 5, 4, 12, 4, 2 };
MyCheckbox checkbox[ ];
TextArea block[ ];
int indices[ ];
public void init( ) {
checkbox = new MyCheckbox[ count ];
block = new TextArea[ count ];
for( int i = 0; i < count; ++ i ) {
String label = Integer.toString( i );
block[ i ] = new TextArea( label, height[ i ], 60 );
checkbox[ i ] = new MyCheckbox( label, this, i );
}
Panel checkPanel = new Panel( );
for( int i = 0; i < count; ++ i )
checkPanel.add( checkbox[ i ] );
add( checkPanel );
for( int i = 0; i < count; ++ i )
add( block[ i ] );
indices = new int[ count ];
for( int i = 0; i < count; ++ i )
indices[ i ] = i + 1;
}
void showHideBlock( int index, boolean show ) {
if( show ) {
add( block[ index ], indices[ index ] );
layout( );
for( int i = index + 1; i < count; ++ i )
indices[ i ] ++;
} else {
remove( block[ index ] );
layout( );
for( int i = index + 1; i < count; ++ i )
indices[ i ] --;
}
}
}
class MyCheckbox extends Checkbox {
LayoutTestApplet container;
int index;
public MyCheckbox( String label, LayoutTestApplet container, int
index ) {
super( label, null, true );
this.container = container;
this.index = index;
}
public boolean action( Event event, Object argument ) {
container.showHideBlock( index, super.getState( ));
return true;
}
}