You cannot gain a direct access to another's application controls (like buttons, checkboxes, list and other UI elements) even if it is written in Java, unless that application provide some options to control its UI (and i doubt many applications provide such a thing).
So there could be just two ways (both are equally bad i guess):
1. Use some 3rd party native library to interact with application, but there will be a lot of pain and problems in that case depending on the tested application.
2. Use Robot and emulate key and mouse events over that application window to do something (like pressing a button, filling a textfield or scrolling a list), but that will require exact coordinates for components which you also can't retrieve, so you might only hardcode these coordinates and pray that noone moves/resizes the tested window while test is running.
To summ up - it is not the best thing to write UI test application using Java.
Actually i bet it might be a pain to write it using other languages aswell in some cases.
Maybe i am terribly wrong and someone can share a way to do such things in Java in a better way...
P.S. Small robot example (filling abstract login form):
public static void main ( String[] args )
{
fillForm ();
}
private static void fillForm ()
{
try
{
Robot r = new Robot ();
// Set to true so we will wait for events to process
// Still we might need some delays to let application take the input in some cases
r.setAutoWaitForIdle ( true );
// Login
typeKey ( r, KeyEvent.VK_A );
typeKey ( r, KeyEvent.VK_D );
typeKey ( r, KeyEvent.VK_M );
typeKey ( r, KeyEvent.VK_I );
typeKey ( r, KeyEvent.VK_N );
// Tab to password field
typeKey ( r, KeyEvent.VK_TAB );
// Password
typeKey ( r, KeyEvent.VK_P );
typeKey ( r, KeyEvent.VK_A );
typeKey ( r, KeyEvent.VK_S );
typeKey ( r, KeyEvent.VK_S );
// Process form
typeKey ( r, KeyEvent.VK_ENTER );
}
catch ( AWTException e )
{
e.printStackTrace ();
}
}
private static void typeKey ( Robot r, int a )
{
r.keyPress ( a );
r.keyRelease ( a );
}