@Override
	public void mouseDragged(MouseEvent e) {
        int x = e.getX();
        int y = e.getY();
        int width=0, height=0;
        Object source = e.getSource();
        if(source instanceof Window) {
            Window window = (Window) source;
            width=window.getWidth();
            height=window.getHeight();
        } else if (GLProfile.isAWTAvailable() && source instanceof java.awt.Component) {
            java.awt.Component comp = (java.awt.Component) source;
            width=comp.getWidth();
            height=comp.getHeight();
        } else {
            throw new RuntimeException("Event source neither Window nor Component: "+source);
        }
        float thetaY = 360.0f * ( (float)(x-prevMouseX)/(float)width);
        float thetaX = 360.0f * ( (float)(y-prevMouseY)/(float)height);
        
        prevMouseX = x;
        prevMouseY = y;

        if(mouseID == 0){
        	view_rotx += thetaX;
        	view_roty += thetaY;
        }
        else if(mouseID == 1){
        	X_pos += thetaY/3;
        	Y_pos -= thetaX/3;
        }
        else if(mouseID == 2){
        	Z_pos += thetaX;
        }
      }