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 code—you'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.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.2.23