-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
1.2.2
-
x86
-
windows_95
Name: clC74495 Date: 09/14/99
Scroll using ScrollPane class with TextField is slower (about 1/4(e.g.) speed )than that of with earlier JDK.
The applet made by using JDK1.1.2 dosen't work properly when
using Java-plugin(ver1.2.2), in the following case;
Deploy TextField as top and Canvas as bottom on Panel object,
and put it onto ScrollPane object.
Then set "TextField.visible = true", the scrolling speed is
so slower than the case set "TextField.visible = false".
I also found that the scroll of Canvas with String object is
slower than without String object.
It looks like Re-painting of the canvas delays scrolling.
Sample source code is below;
public class DialogTestApplet extends Applet implements ActionListener {
private Panel Panel1 = new Panel();
private Button Button1 = new Button( "Dialog" );
private Label Label1 = new Label( "Label1" );
private MyDialog Dialog1 = null;
private PopupMenu pm2 = new PopupMenu();
private ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED) ;
private Panel scrollPanel = new Panel() ;
private MyCanvas scrollCanvas = new MyCanvas();
private PopupHelpMouseListener phml = new PopupHelpMouseListener();
private MyContainer scrollContainer = new MyContainer();
private TextField inputField = new TextField("abc");;
public DialogTestApplet() {
}
public void init() {
scrollPanel.setLayout( null );
Panel1.add( Button1 );
Panel1.add( Label1 );
add( Panel1 );
scrollCanvas.setSize( 500, 400 );
scrollPanel.setSize( 500, 400 );
scrollPane.setSize( 400, 300 );
inputField.setBounds( 50, 50, 40, 20 );
scrollPanel.add( inputField );
scrollPanel.add( scrollCanvas );
scrollPane.add( scrollPanel );
add( scrollPane );
Button1.addActionListener( this );
Component co = this;
while(!((co = co.getParent()) instanceof Frame)){}
Frame f = (Frame)co;
Dialog1 = new MyDialog( f );
pm2.add( "Menu1" );
add( pm2 );
Label1.addMouseListener( phml );
Button1.addMouseListener( phml );
}
public void close() {
System.out.println( "close" );
}
public void destroy() {
System.out.println( "destroy" );
}
public void actionPerformed(ActionEvent e) {
Dialog1.show();
if ( scrollContainer.isVisible() == true ) {
scrollContainer.setVisible( false );
} else {
scrollContainer.setVisible( true );
}
}
}
public class MyContainer extends Container {
private TextField inputField = new TextField("abc");;
public MyContainer() {
super();
setLayout(null);
inputField.setBounds( 0, 0, 38, 18 );
add(inputField);
setVisible(true);
}
}
public class MyCanvas extends Canvas {
private static int count = 0;
public MyCanvas() {
}
public void paint(Graphics g) {
Rectangle r = getBounds();
g.setColor(Color.yellow);
g.fillRect(0, 0, r.width, r.height);
g.setColor(Color.blue);
g.drawLine(0, 0, r.width, r.height);
g.setColor(Color.red);
g.drawLine(0, r.height, r.width, 0);
g.setColor(Color.black);
for ( int i=0; i<20; i++ ) {
int y = i * 20;
g.drawLine(0, y, r.width, y);
g.drawLine(y, 0, y, r.height);
}
for ( int i=0; i<20; i++ ) {
g.drawString( "ScrollPane Test", i*15, i*15 );
}
System.out.println( count++ );
}
}
(Review ID: 95226)
======================================================================