package ip.apurva;

import ip.gui.ImageSequence;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;


public class Myimage extends Frame implements WindowListener, ActionListener {
  ip.gui.frames.AnimateFrame af = new ip.gui.frames.AnimateFrame();
  Panel p = new Panel();
  Button savebutt = new Button("Save");
  Button openbutt = new Button("Open");

  ImageSequence IS = new ImageSequence();
////////////////////////////////////////////////////
//methods for windowlistener
  public void windowClosing(WindowEvent e) {
    dispose();
  }

  public void windowClosed(WindowEvent e) {
  };
  public void windowDeiconified(WindowEvent e) {
  };
  public void windowIconified(WindowEvent e) {
  };
  public void windowActivated(WindowEvent e) {
  };

  public void windowDeactivated(WindowEvent e) {
  };
  public void windowOpened(WindowEvent e) {
  };

////////////////////////////////////////////////////
  public void actionPerformed(ActionEvent e) {
    Button b = (Button) e.getSource();
    if (b == savebutt) {
      af.saveImages();
      return;
    } else if (b == openbutt) {
      ip.gui.frames.AnimateFrame ax = new ip.gui.frames.AnimateFrame();
      ax.openImages();
      ax.setRunning(true);
      ax.setVisible(true);
      return;
    }
  }
////////////////////////////////////////////////////
  public void init() {
    add(p);
    p.add(savebutt);
    p.add(openbutt);
    p.setLayout(new GridLayout(0, 2));
    this.setLayout(new GridLayout(0, 1));
    addWindowListener(this);
    savebutt.addActionListener(this);
    openbutt.addActionListener(this);
  }

  public Myimage(ip.gui.frames.AnimateFrame ax) {
    super("gz frame");
    init();
    af = ax;
    setSize(200, 200);
    setVisible(true);
    show();

  }

  public static void main(String args[]) {
    Myimage mn = new Myimage(new ip.gui.frames.AnimateFrame());
  }
}