package j3deditor.bin;


import j3deditor.bin.util.Utilities;

import java.awt.Color;

import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;


/**
 * Desktop pane for internal frames.
 *
 * @author Risto Seene
 * 
 * @see javax.swing.JDesktopPane
 * @see javax.swing.JInternalFrame
 */
public class MainDesktop extends JDesktopPane{

	/**
	 * Creates an instance of <code>MainDesktop</code>
	 * and specifies its drag mode.
	 */
	public MainDesktop(){
		setBackground(new Color(150, 150, 150));
		try{
			setDragMode(Utilities.userdata.getIntData("desktoppane_dragmode"));
		} catch(Throwable t){
		}
	}

	/**
	 * Closes the given internal frame by calling its <code>doDefaultCloseAction()</code> method.
	 * 
	 * @param window
	 * 	internal frame that will be closed
	 */
	public void closeWindow(InnerFrame window){
		window.doDefaultCloseAction();
	}

	/**
	 * Closes all internal frames attached to this desktop pane by
	 * calling their <code>doDefaultCloseAction()</code> method.
	 */
	public void closeAllWindows(){
		JInternalFrame[] windows = this.getAllFrames();
		for(int i=0; i<windows.length; i++){
			windows[i].doDefaultCloseAction();
		}
	}

}
