package asandatabasebrowser.action;

import java.awt.event.ActionEvent;
import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.JFrame;

import asandatabasebrowser.AsanDatabaseBrowser;


public class CloseAllFrameAction extends AbstractAction {
	final AsanDatabaseBrowser tools;
	public CloseAllFrameAction(AsanDatabaseBrowser tools) {
		super("すべてのウィンドウを閉じる");
		putValue(SHORT_DESCRIPTION, "すべてのウィンドウを閉じる");
		putValue(LONG_DESCRIPTION, "すべてのウィンドウを閉じる");
		this.tools = tools;
	}

	public void actionPerformed(ActionEvent ev) {
		List list = tools.getFrameList();
		for (int i=list.size()-1; i>=0; i--) {
			JFrame frame = (JFrame) list.get(i);
			tools.close(frame);
			frame.setVisible(false);
			frame.dispose();
		}
	}
}

