O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Robot's Window

So how do you start creating the Robot? This project uses Java Swing to present the window you see in Figure 7.1. The main class, RobotProject (called that so as not to conflict with the Java Robot class), extends the Swing JFrame class and implements the ActionListener class to be able to handle events such as button clicks:

					class RobotProject extends JFrame implements ActionListener
{
    .
    .
    .
}

You can find the significant methods of the JFrame class in Table 7.1.

Table 7.1. Significant Methods of the javax.swing.JFrame Class
MethodDoes This
protected JRootPane createRootPane()Called internally in order to create the default rootPane object
protected void frameInit()Called internally to initialize the JFrame object ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required