/*
 * @(#)SaveOpenDemo.java
 *
 * Copyright 2001 Thomas P. Hayes, All Rights Reserved.
 *
 * This software is the proprietary information of Thomas P. Hayes.
 * Use outside the CSPP 535 course taught by the author is subject
 * to license agreement.
 */

package saveopen;
import saveopen.presentation.*;
import saveopen.translation.*;
import util.*;
import puzzle.*;
import configure.ConfigureDemo;
import javax.swing.*;
import java.awt.*;

/**
 * This demo lets the user select a frame, and save it to file,
 * or conversely, open a file and display the stored frame.
 */
public class SaveOpenDemo {
    
    /**
     * This constructor is here in case you want to use this demo
     * inside another piece of code, instead of just running main().
     */
    public SaveOpenDemo() {
        SaveOpenDemoFrame f = new SaveOpenDemoFrame();
        f.setTitle("Save/Open Window");
        SaveOpenDemoMenuHandler handler = new SaveOpenDemoMenuHandler(f);
        f.setSize(300,200);
        f.setVisible(true);
        SquarePuzzle puzz = new SquarePuzzle(4,4);
        ActionPanel disp = new SquarePuzzleDisplay(puzz);
        
        SquarePuzzleApp sapp = new SquarePuzzleApp(4,4);
        (sapp.disp).addActionListener(handler);
        (sapp.disp.setBackground(Color.blue));

        JFrame conf = new ConfigureDemo(disp);
        JFrame test = new JFrame();
        JButton testBut = new JButton("Select me");
        test.getContentPane().add(testBut);
        JMenuBar mb = new JMenuBar();
        JMenu m = new JMenu("Serialize me");
        JMenuItem mi = new JMenuItem("Go!");
        m.add(mi);
        mb.add(m);
        test.setJMenuBar(mb);
        test.pack();
        test.setVisible(true);
        testBut.addActionListener(handler);
        disp.addActionListener(handler);
    }
    
    /**
     * Runs the demo. 
     */
    public static void main(String[] args) {
        SaveOpenDemo theDemo = new SaveOpenDemo();
    }
}




