Page 188 - The Definitive Guide to Building Java Robots
P. 188

Preston_5564C06.fm  Page 169  Friday, September 23, 2005  5:13 AM



                                                                                   CHAPTER 6  ■  VISION  169


















                        Figure 6-2. SimpleSwing

                        Example 6-3. SimpleSwing.java

                        package com.scottpreston.javarobot.chapter6;

                        import java.awt.Color;
                        import java.awt.Container;

                        import javax.swing.JFrame;

                        public class SimpleSwing extends JFrame {

                            // constructor
                            public SimpleSwing()  {
                                // calls JFrame with title
                                super("Java Robots Are Cool!");
                                // set look & feel
                                WindowUtilities.setNativeLookAndFeel();
                                // closes
                                addWindowListener(new ExitListener());
                                // sets size
                                setSize(320, 240);
                                // sets pane of content
                                Container content = getContentPane();
                                // sets color to white
                                content.setBackground(Color.white);
                                // shows frame
                                setVisible(true);
                            }

                              public static void main(String[] args) throws Exception{
                                  SimpleSwing test = new SimpleSwing();

                              }
                        }
   183   184   185   186   187   188   189   190   191   192   193