gt: 		if (e.getID() == MouseEvent.MOUSE_PRESSED) {
context: /*******************************************************************************
   * This is part of SketchChair, an open-source tool for designing your own furniture.
   *     www.sketchchair.cc
   *     
   *     Copyright (C) 2012, Diatom Studio ltd.  Contact: hello@diatom.cc
   * 
   *     This program is free software: you can redistribute it and/or modify
   *     it under the terms of the GNU General Public License as published by
   *     the Free Software Foundation, either version 3 of the License, or
   *     (at your option) any later version.
   * 
   *     This program is distributed in the hope that it will be useful,
   *     but WITHOUT ANY WARRANTY; without even the implied warranty of
   *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *     GNU General Public License for more details.
   * 
   *     You should have received a copy of the GNU General Public License
   *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
   ******************************************************************************/
  package ModalGUI;
  
  import java.awt.event.KeyEvent;
  import java.awt.event.MouseEvent;
  import java.awt.event.MouseWheelEvent;
  
  import javax.media.opengl.GL;
  
  import cc.sketchchair.sketch.LOGGER;
  import processing.core.PApplet;
  import processing.core.PConstants;
  import processing.core.PFont;
  import processing.core.PGraphics;
  import processing.core.PImage;
  
  public class GUIPanel extends GUIComponent {
  
  	public GUIComponents components = new GUIComponents();
  	protected float currentX = 15;
  	float currentY = 20f;
  
  	float minimizedH = 5;
  	float minimizedW = 5;
  	float maximizedH = 5;
  	float maximizedW = 5;
  
  	public float spacingX = 10;
  	public float spacingY = 10;
  	public boolean minimized = false;
  
  	public boolean isDragging = false;
  	public boolean isDraggable = false;
  
  	private float selectBarHeight = 15;
  	public boolean autoHide = false;
  	private float cornerRad = 7f;
  	PGraphics canvas = null;
  	PImage bufferedCanvas = null;
  	public boolean useCanvas = false;
  	float scrollX = 0;
  	float scrollY = 0;
  
  	float prevScrollX = 0;
  	float prevScrollY = 0;
  
  	float deltaScrollX = 0;
  	float deltaScrolY = 0;
  
  	private float bottomScrollY;
  	private float rightScrollX;
  	private float topScrollY;
  	private float leftScrollX;
  	public boolean useScroolBarX;
  	public boolean useScroolBarY;
  
  	GUIScrollbar sliderX = null;
  	GUIScrollbar sliderY = null;
  	public boolean hideSelectBar = false;
  	public boolean hideMinimize = true;
  
  	GUIPanel dockedPanelTop = null;
  	GUIPanel dockedPanelBottom = null;
  	int DOC_TOP = 0;
  	int DOC_BOTTOM = 0;
  	private GUIButton minimize;
  
  	PImage mask = null;
  	String tittle = "";
  	private boolean invisible = false;
  	public boolean renderBorder = true;
  	public PImage tabUpImg = null;
  	public PImage tabDownImg = null;
  
  	
  	
  	public GUIPanel(float x, float y, float w, float h, boolean useCanvas,
  			PApplet applet, ModalGUI c) {
  		this(x, y, w, h, c);
  		makeCanvas(w, h, applet);
  		
  		//this.useCanvas = useCanvas;
  
  	}
  
  	public GUIPanel(float x, float y, float w, float h, ModalGUI c) {
  		this.setController(c);
  		this.minimizedH = 10;
  		this.minimizedW = w;
  		this.maximizedH = h;
  		this.maximizedW = w;
  		this.setPos(x, y);
  		this.setSize(w, h);
  		this.mask = c.applet.loadImage("mask.png");
  	}
  
  	public void add(GUIComponent component) {
  
  		this.components.add(component);
  
  		component.setController(this.controller);
  
  		component.setParentPanel(this);
  
  		//if(component.getY() > currentY && this.useCanvas)
  		//	currentY = component.getY();
  
  		//if(component.getX() > currentX && this.useCanvas)
  		//	currentX = component.getX();
  
  		if (component.getY() + component.getHeight() > this.getY()
  				+ this.getHeight() - 20
  				&& useScroolBarY) {
  			this.bottomScrollY = (component.getY() + (component.getHeight() * 2))
  					- (this.getY() + this.getHeight());
  			this.updateYSlider(0, this.bottomScrollY);
  		}
  		if (component.getX() + component.getWidth() > this.getX()
  				+ this.getWidth()
  				&& useScroolBarX) {
  			this.rightScrollX = component.getX() + component.getWidth();
  			this.updateXSlider(0, this.rightScrollX - this.getX());
  
  		}
  
  		if (this.useCanvas)
  			this.updateCanvas();
  
  	}
  
  	public void clear() {
  		this.currentX = 5;
  		this.currentY = 20;
  		this.bottomScrollY = 0;
  		this.rightScrollX = 0;
  		this.sliderX = null;
  		this.sliderY = null;
  
  		//this.updateXSlider(0, 0);
  		//this.updateYSlider(0, 0);
  		this.components.clear();
  	}
  
  	public void docTo(GUIPanel panel) {
  
  		//if(DOC_TOP == this.DOC_TOP)
  		this.dockedPanelTop = panel;
  
  		//if(DOC_TOP == this.DOC_BOTTOM)
  		//	this.dockedPanelBottom = panel;
  
  	}
  
  	@Override
  	public boolean hasFocus() {
  		if (this.hasFocus || this.components.hasFocus())
  			return true;
  		else
  			return false;
  
  	}
  
  	@Override
  	public void hide() {
  		this.visible = false;
  		this.components.hideAll();
  	}
  
  	void hideAll() {
  		this.components.hideAll();
  	}
  
  	@Override
  	public boolean isMouseOver() {
  		int mouseX = controller.applet.mouseX;
  		int mouseY = controller.applet.mouseY;
  
  		if (mouseX >= this.getX() && mouseY >= this.getY()
  				&& mouseX <= this.getX() + this.getWidth()
  				&& mouseY <= this.getY() + this.getHeight())
  			return true;
  
  		if (this.components.isMouseOver())
  			return true;
  
  		return false;
  
  	}
  
  	private boolean isMouseOverMoveBar() {
  		int mouseX = controller.applet.mouseX;
  		int mouseY = controller.applet.mouseY;
  
  		return mouseX >= this.getX() && mouseY >= this.getY()
  				&& mouseX <= this.getX() + this.getWidth()
  				&& mouseY <= this.getY() + this.selectBarHeight;
  
  	}
  
  	@Override
  	public void keyEvent(KeyEvent theKeyEvent) {
  		this.components.keyEvent(theKeyEvent);
  	}
  
  	private void makeCanvas(float w, float h, PApplet applet) {
  		this.useCanvas = true;
  		//this.canvas = applet.createGraphics((int)w, (int) ((int)h-this.selectBarHeight-2), PApplet.P2D);
  		//this.bufferedCanvas = this.canvas.get();
  
  		//this.canvas.alpha(0);
  		//this.canvas.smooth();
  		//this.canvas.alpha(255);
  	}
  
  	public void minimizeToggle(GUIEvent e) {
  
  		this.minimized = !this.minimized;
  
  		if (this.minimized) {
  			hideAll();
  			this.setSize(this.minimizedW, this.minimizedH);
  		} else {
  			showAll();
  			this.setSize(this.maximizedW, this.maximizedH);
  		}
  	}
  
  	@Override
  	public void mouseWheelMoved(MouseWheelEvent e) {
  		if (!this.visible)
  			return;
  		this.components.mouseWheelMoved(e);
  
  	}
  	
  	
  	@Override
  	public void mouseEvent(MouseEvent e) {
  
  		if (!this.visible)
  			return;
  
  		this.components.mouseEvent(e);
  
  		if (sliderX != null)
  			sliderX.mouseEvent(e);
  		if (sliderY != null)
  			sliderY.mouseEvent(e);
  
  