Robot Issue

I want to do the following with the java.awt.robot class:

1. Move the mouse so it can click multiple times on one of the arrow buttons on a scrollbar (JTable in a JScrollPane).

2. somehow allow the screen to update itself.

3. use the updated scrollbar and table position values in some calculations

4. double-click a table cell (String value), Select All, and type a new phrase

At the moment, I have it moving the mouse alright (I figured out how to get the ArrowButton objects' locations from the UI object). It clicks and does everything after my initial robot-starting button click event is handled. (One screen update happens at the end of all the processing)

I would like to have the new events processed during the handling of the main button click event. The calcuations that are expected to have new values still have the old values because the GUI won't update them until after the main button press.

I believe the solution is to use threads and to somehow "mess with" the EventDispatcher method. I've tried a bunch of things including using the SwingWorker class, but it doesn't yet work as I would have expected.

[1176 byte] By [monsteroftheida] at [2007-11-26 14:38:14]
# 1

Have you tried simply putting a short pause after each Robot mouse click?try {

Thread.sleep(20);

} catch (InterruptedException ex) {

// Ignore

}

If that doesn't help, then you are probably right that you need to run your Robot code in a separate thread.

TimRyanNZa at 2007-7-8 8:19:16 > top of Java-index,Desktop,Core GUI APIs...
# 2
Well I found the answer to my problem.I was doing some robot clicking DURING the button press thread when I should have done it AFTER. I put my mainrobot initiating call into a thread (and not just the second half of my code) and everything works perfectly.
monsteroftheida at 2007-7-8 8:19:16 > top of Java-index,Desktop,Core GUI APIs...
# 3

Hello monsteroftheid,

Would you mind posting your code here on how you found the scrollbar arrow key positions within the UI object()?

I am trying do to the same thing with java.awt.Robot to get a java.awt.Scrollbar to move up and down "programmatically" in response to mouse wheel actions.

Thanks, Paul

pgraf1404a at 2007-7-8 8:19:16 > top of Java-index,Desktop,Core GUI APIs...