Making the Robot Reappear


There are a few last items to take care of in the Robot project. To end the switch statement, the code displays an error message if it can't understand an entered command. Also, the TRy statement that encloses all the Robot operations ends with a catch statement that reports any errors. And at the very end of the code, the setVisible method of JFrame brings the Robot back into view:

     default:          System.out.println(             "I didn't understand that command."); }     catch (Exception ex){System.out.println("Error: " +         ex.getMessage());}     setVisible(true); } 

That completes the codeyou're ready to start running other programs via remote control, sending keystrokes and mouse events, taking screen shots, and more. There's a lot of power here.

NOTE

Download the complete source code for the Robot project, RobotProject.java, at the Sams website. After compiling the needed file (to create RobotProject.class), you can run it and get started controlling other programs.




    Java After Hours(c) 10 Projects You'll Never Do at Work
    Java After Hours: 10 Projects Youll Never Do at Work
    ISBN: 0672327473
    EAN: 2147483647
    Year: 2006
    Pages: 128

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net