001package horstmann.ch10_proxy;
002import javax.swing.JFrame;
003import javax.swing.JLabel;
004import javax.swing.JTabbedPane;
005
006/**
007   This program demonstrates the use of the image proxy.
008   Images are only loaded when you press on a tab.
009 */
010public class ProxyTester
011{
012        public static void main(String[] args)
013        {
014                JTabbedPane tabbedPane = new JTabbedPane();
015                for (String name : imageNames)
016                {
017                        JLabel label = new JLabel(new ImageProxy(name));
018                        tabbedPane.add(name, label);
019                }
020
021                JFrame frame = new JFrame();
022                frame.add(tabbedPane);
023
024                frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
025                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
026                frame.setVisible(true);
027        }
028
029        private static final String[] imageNames =
030                {
031                                "devonian.gif",
032                                "permian.gif",
033                                "jurassic1.gif",
034                                "jurassic2.gif",
035                                "cretaceous1.gif",
036                                "cretaceous2.gif",
037                                "cretaceous3.gif",
038                                "eocene1.gif",
039                                "eocene2.gif",
040                                "oligocene.gif",
041                                "miocene.gif",
042                                "pleistocene.gif"
043                };
044
045        private static final int FRAME_WIDTH = 500;
046        private static final int FRAME_HEIGHT = 300;
047}