FileDocCategorySizeDatePackage
Demo.javaAPI DocExample3806Mon Jan 09 11:02:00 GMT 2006None

Demo

public class Demo extends JFrame

Fields Summary
protected AnimatedPanel
animated
protected InfiniteProgressPanel
glassPane
protected CardLayout
carder
protected JPanel
cardPane
Constructors Summary
public Demo()

        super("Infinite Progress Demo");

        build();

        pack();
        setResizable(false);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLocationRelativeTo(null);
    
Methods Summary
protected voidbuild()

        getContentPane().setLayout(new BorderLayout());
        getContentPane().add(BorderLayout.CENTER, buildTabbedPane());
    
protected java.awt.ContainerbuildAnimatedPanel()

        carder = new CardLayout();
        cardPane = new JPanel(carder);

        JPanel pane = new JPanel(new BorderLayout());
        JTable table = new JTable(new CountTableModel());
        JScrollPane scrollPane = new JScrollPane(table);
        pane.add(BorderLayout.CENTER, scrollPane);

        JPanel buttons = new JPanel();
        JButton button = new JButton("Start");
        buttons.add(button);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                carder.show(cardPane, "animation");
                animated.start();

                Thread performer = new Thread(new Runnable() {
	                public void run() {
	                    try {
	                       Thread.sleep(5000);
	                    } catch (InterruptedException ie) { }

	                    animated.stop();
	                    carder.show(cardPane, "form");
	                }
	            }, "Performer");
	            performer.start();
            }
        });
        pane.add(BorderLayout.SOUTH, buttons);

        animated = new AnimatedPanel("Waiting in vain...",
                                     UIHelper.readImageIcon("network.png"));
        animated.setFont(animated.getFont().deriveFont(Font.BOLD, 16));

        cardPane.add("form", pane);
        cardPane.add("animation", animated);
        return cardPane;
    
protected java.awt.ContainerbuildInfinitePanel()

        JPanel pane = new JPanel(new BorderLayout());

        glassPane = new InfiniteProgressPanel();
        setGlassPane(glassPane);

        JTable table = new JTable(new CountTableModel());
        JScrollPane scrollPane = new JScrollPane(table);
        pane.add(BorderLayout.CENTER, scrollPane);

        JPanel buttons = new JPanel();
        JButton button = new JButton("Start");
        buttons.add(button);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                glassPane.start();
	            Thread performer = new Thread(new Runnable() {
	                public void run() {
	                    try {
	                       Thread.sleep(5000);
	                    } catch (InterruptedException ie) { }
	                    glassPane.stop();
	                }
	            }, "Performer");
	            performer.start();
            }
        });
        pane.add(BorderLayout.SOUTH, buttons);

        return pane;
    
protected java.awt.ContainerbuildTabbedPane()

        JTabbedPane tabbedPane = new JTabbedPane();
        tabbedPane.add("Animated", buildAnimatedPanel());
        tabbedPane.add("Infinite", buildInfinitePanel());
        return tabbedPane;
    
public static voidmain(java.lang.String[] args)

        Demo d = new Demo();
        d.setVisible(true);