001package horstmann.ch06_scene1;
002import java.awt.BorderLayout;
003import javax.swing.JButton;
004import javax.swing.JFrame;
005import javax.swing.JPanel;
006
007/**
008   A program that allows users to edit a scene composed
009   of items.
010 */
011public class SceneEditor
012{
013        public static void main(String[] args)
014        {
015                JFrame frame = new JFrame();
016                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
017
018                final SceneComponent scene = new SceneComponent();
019
020                JButton houseButton = new JButton("House");
021                houseButton.addActionListener(event -> scene.add(new HouseShape(20, 20, 50)));
022
023                JButton carButton = new JButton("Car");
024                carButton.addActionListener(event -> scene.add(new CarShape(20, 20, 50)));
025
026                JButton removeButton = new JButton("Remove");
027                removeButton.addActionListener(event -> scene.removeSelected());
028
029                JPanel buttons = new JPanel();
030                buttons.add(houseButton);
031                buttons.add(carButton);
032                buttons.add(removeButton);
033
034                frame.add(scene, BorderLayout.CENTER);
035                frame.add(buttons, BorderLayout.NORTH);
036                frame.setSize(300, 300);
037                frame.setVisible(true);
038        }
039}
040
041