1  import java.awt.*;
  2  import java.awt.geom.*;
  3  import java.awt.event.*;
  4  import javax.swing.*;
  5  
  6  /**
  7     A program that allows users to edit a scene composed
  8     of items.
  9  */
 10  public class SceneEditor
 11  {
 12     public static void main(String[] args)
 13     {
 14        JFrame frame = new JFrame();
 15        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 16  
 17        SceneComponent scene = new SceneComponent();
 18  
 19        JButton houseButton = new JButton("House");
 20        houseButton.addActionListener(new
 21           ActionListener()
 22           {
 23              public void actionPerformed(ActionEvent event)
 24              {
 25                 scene.add(new HouseShape(20, 20, 50));
 26              }
 27           });
 28  
 29        JButton carButton = new JButton("Car");
 30        carButton.addActionListener(new
 31           ActionListener()
 32           {
 33              public void actionPerformed(ActionEvent event)
 34              {
 35                 scene.add(new CarShape(20, 20, 50));
 36              }
 37           });
 38  
 39        JButton removeButton = new JButton("Remove");
 40        removeButton.addActionListener(new
 41           ActionListener()
 42           {
 43              public void actionPerformed(ActionEvent event)
 44              {
 45                 scene.removeSelected();
 46              }
 47           });
 48  
 49        JPanel buttons = new JPanel();
 50        buttons.add(houseButton);
 51        buttons.add(carButton);
 52        buttons.add(removeButton);
 53  
 54        frame.add(scene, BorderLayout.CENTER);
 55        frame.add(buttons, BorderLayout.NORTH);
 56        frame.setSize(300, 300);
 57        frame.setVisible(true);
 58     }
 59  }
 60  
 61