tags:

views:

71

answers:

1

Hi,

I have a JTextPane integration that should perform predefined steps on keypress events. If I type manually it seems to work fine. But I have to emulate keypress events on this integration for test purposes. The test enviroment is such that the given JTextPane is not added to any other controls. I tried to use Robot class, after set the visibility and editablety of the JTextPane to true, and requesting focus. The problem is that I could not see any key press events coming, and the content of the JTextPane is still empty. Please give me some advice. Thank you,

Peter

A: 

The test enviroment is such that the given JTextPane is not added to any other controls

Then the component is not visible on the screen and cannot accept focus, therefore the Robot won't work.

I'm not sure but you might be able to use

textPane.dispatchEvent(....).

Or if that doesn't work then you can use:

textPane.getDocument().insertString(...);
camickr