In pure Java, no. The reason is Java or any other program doesn't have the handle to the other program's process/threads (which is good because that would be a severe security breach if it did). However, In languages that compile down to machine code, you can manipulate the hardware and spoof keystrokes/mouse movement etc. that will be passed to the program by your OS. Native Java can't do this, but the Robot class allows Java to spoof keystrokes and mouse movement by linking some native code for use by your Java program.
The same is true with Java graphics. AWT is a java interface to native components, as well as other graphics libraries that allow for graphics card acceleration. SWING may be written in Java, but it still needs to access AWT methods to draw to the screen.