./test/java/awt/TextArea/UsingWithMouse/SelectionAutoscrollTest.java
Print this page
rev 293 : Ensure that scrolling and text selection is really performed on Gnome.
@@ -54,10 +54,11 @@
public class SelectionAutoscrollTest extends Applet {
TextArea textArea;
Robot robot;
final int desiredSelectionEnd = ('z'-'a'+1)*2; // 52
+ final int SCROLL_DELAY = 10; // 10ms
public void start () {
createObjects();
manipulateMouse();
checkResults();
@@ -139,13 +140,21 @@
}
void moveMouseBelowTextArea( boolean shift ) {
Dimension d = textArea.getSize();
Point l = textArea.getLocationOnScreen();
+ int x = (int)(l.x+d.width*.5);
int y = (int)(l.y+d.height*1.5);
if( shift ) y+=15;
- robot.mouseMove( (int)(l.x+d.width*.5), y );
+ robot.mouseMove( x, y );
+ // it is needed to add some small delay on Gnome
+ waitUntilScrollIsPerformed();
+ }
+
+ void waitUntilScrollIsPerformed() {
+ try { Thread.sleep( SCROLL_DELAY ); }
+ catch( Exception e ) { throw new RuntimeException( e ); }
}
void checkResults() {
//try { Thread.sleep( 30*1000 ); }
//catch( Exception e ) { throw new RuntimeException( e ); }