⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicinternalframeui.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	}        public void mouseReleased(MouseEvent e) {           if (discardRelease) {	     discardRelease = false;	     return;	  }	    if (resizeDir == RESIZE_NONE) {	        getDesktopManager().endDraggingFrame(frame);			dragging = false;	    } else {	      Container c = frame.getTopLevelAncestor();	      if (c instanceof JFrame) {		((JFrame)frame.getTopLevelAncestor()).getGlassPane().setCursor(                  Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));            	        ((JFrame)frame.getTopLevelAncestor()).getGlassPane(                  ).setVisible(false);	      } else if (c instanceof JApplet) {		((JApplet)c).getGlassPane().setCursor(		  Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));		((JApplet)c).getGlassPane().setVisible(false);	      } else if (c instanceof JWindow) {		((JWindow)c).getGlassPane().setCursor(                  Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));		((JWindow)c).getGlassPane().setVisible(false);	      } else if (c instanceof JDialog) {		((JDialog)c).getGlassPane().setCursor(                  Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));		((JDialog)c).getGlassPane().setVisible(false);	      }	      getDesktopManager().endResizingFrame(frame);	    }            _x = 0;            _y = 0;            __x = 0;            __y = 0;            startingBounds = null;            resizeDir = RESIZE_NONE;        }                        public void mousePressed(MouseEvent e) {            Point p = SwingUtilities.convertPoint((Component)e.getSource(),                         e.getX(), e.getY(), null);            __x = e.getX();            __y = e.getY();            _x = p.x;            _y = p.y;            startingBounds = frame.getBounds();	    resizeDir = RESIZE_NONE;            if(!frame.isSelected()) {                try { frame.setSelected(true); }		catch (PropertyVetoException e1) { }            }	    Insets i = frame.getInsets();	    Point ep = new Point(__x, __y);            if (e.getSource() == getNorthPane()) {		Point np = getNorthPane().getLocation();		ep.x += np.x;		ep.y += np.y;	    }            if (e.getSource() == getNorthPane()) {		if (ep.x > i.left && ep.y > i.top && ep.x < frame.getWidth() - i.right) {		    getDesktopManager().beginDraggingFrame(frame);		    dragging = true;		    return;		}            }	    if (!frame.isResizable()) {	      return;	    }	    if (e.getSource() == frame || e.getSource() == getNorthPane()) {                if (ep.x <= i.left) {		    if (ep.y < resizeCornerSize + i.top) {                        resizeDir = NORTH_WEST;                    } else if (ep.y > frame.getHeight()                              - resizeCornerSize - i.bottom) {                        resizeDir = SOUTH_WEST;		    } else {                          resizeDir = WEST;}                } else if (ep.x >= frame.getWidth() - i.right) {		    if (ep.y < resizeCornerSize + i.top) {                        resizeDir = NORTH_EAST;                    } else if (ep.y > frame.getHeight()                               - resizeCornerSize - i.bottom) {                        resizeDir = SOUTH_EAST;		    } else {                                       resizeDir = EAST;		    }                } else if (ep.y <= i.top) {		    if (ep.x < resizeCornerSize + i.left) {                        resizeDir = NORTH_WEST;                    } else if (ep.x > frame.getWidth()                               - resizeCornerSize - i.right) {                        resizeDir = NORTH_EAST;                    } else {                                     resizeDir = NORTH;		    }                } else if (ep.y >= frame.getHeight() - i.bottom) {		    if (ep.x < resizeCornerSize + i.left) {                        resizeDir = SOUTH_WEST;                    } else if (ep.x > frame.getWidth()                              - resizeCornerSize - i.right) {                        resizeDir = SOUTH_EAST;                    } else {                                      resizeDir = SOUTH;		    }                } else {		  /* the mouse press happened inside the frame, not in the		     border */		  discardRelease = true;		  return;		}		Cursor s = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);                switch (resizeDir) {		case SOUTH:		  s = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);		  break; 		case NORTH:		  s = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);		  break; 		case WEST:		  s = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);		  break; 		case EAST:		  s = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);		  break; 		case SOUTH_EAST:		  s = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);		  break; 		case SOUTH_WEST:		  s = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);		  break; 		case NORTH_WEST:		  s = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);		  break; 		case NORTH_EAST:		  s = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);		  break;		} 		Container c = frame.getTopLevelAncestor();		if (c instanceof JFrame){		  ((JFrame)c).getGlassPane().setVisible(true);		  ((JFrame)c).getGlassPane().setCursor(s);		} else if (c instanceof JApplet){		  ((JApplet)c).getGlassPane().setVisible(true);		  ((JApplet)c).getGlassPane().setCursor(s);		} else if (c instanceof JWindow){		  ((JWindow)c).getGlassPane().setVisible(true);		  ((JWindow)c).getGlassPane().setCursor(s);		} else if (c instanceof JDialog){		  ((JDialog)c).getGlassPane().setVisible(true);		  ((JDialog)c).getGlassPane().setCursor(s);		}		getDesktopManager().beginResizingFrame(frame, resizeDir);		return;            }        }        public void mouseDragged(MouseEvent e) {   	    if ( startingBounds == null ) {	      // (STEVE) Yucky work around for bug ID 4106552		 return;	    }                                                 Point p = SwingUtilities.convertPoint((Component)e.getSource(),                     e.getX(), e.getY(), null);            int deltaX = _x - p.x;            int deltaY = _y - p.y;	    Dimension min = frame.getMinimumSize();	    Dimension max = frame.getMaximumSize();	    int newX, newY, newW, newH;	    Insets i = frame.getInsets();                    // Handle a MOVE             if (dragging) {                if (frame.isMaximum() || ((e.getModifiers() &                        InputEvent.BUTTON1_MASK) !=                        InputEvent.BUTTON1_MASK)) {                    // don't allow moving of frames if maximixed or left mouse                    // button was not used.                    return;                }		int pWidth, pHeight;		Dimension s = frame.getParent().getSize();		pWidth = s.width;		pHeight = s.height;	        newX = startingBounds.x - deltaX;	        newY = startingBounds.y - deltaY;		// Make sure we stay in-bounds		if(newX + i.left <= -__x)		    newX = -__x - i.left + 1;		if(newY + i.top <= -__y)		    newY = -__y - i.top + 1;		if(newX + __x + i.right >= pWidth)		    newX = pWidth - __x - i.right - 1;		if(newY + __y + i.bottom >= pHeight)		    newY =  pHeight - __y - i.bottom - 1;		getDesktopManager().dragFrame(frame, newX, newY);                return;            }            if(!frame.isResizable()) {                return;            }	    newX = frame.getX();	    newY = frame.getY();	    newW = frame.getWidth();	    newH = frame.getHeight();            parentBounds = frame.getParent().getBounds();            switch(resizeDir) {            case RESIZE_NONE:                return;            case NORTH:      		if(startingBounds.height + deltaY < min.height)		    deltaY = -(startingBounds.height - min.height);		else if(startingBounds.height + deltaY > max.height)		    deltaY = max.height - startingBounds.height;		if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;}		newX = startingBounds.x;		newY = startingBounds.y - deltaY;		newW = startingBounds.width;		newH = startingBounds.height + deltaY;                break;            case NORTH_EAST:     		if(startingBounds.height + deltaY < min.height)		    deltaY = -(startingBounds.height - min.height);		else if(startingBounds.height + deltaY > max.height)		    deltaY = max.height - startingBounds.height;		if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;}		if(startingBounds.width - deltaX < min.width)		    deltaX = startingBounds.width - min.width;		else if(startingBounds.width - deltaX > max.width)		    deltaX = -(max.width - startingBounds.width);		if (startingBounds.x + startingBounds.width - deltaX >		    parentBounds.width) {		  deltaX = startingBounds.x + startingBounds.width -		    parentBounds.width;		}		newX = startingBounds.x;		newY = startingBounds.y - deltaY;		newW = startingBounds.width - deltaX;		newH = startingBounds.height + deltaY;                break;            case EAST:      		if(startingBounds.width - deltaX < min.width)		    deltaX = startingBounds.width - min.width;		else if(startingBounds.width - deltaX > max.width)		    deltaX = -(max.width - startingBounds.width);		if (startingBounds.x + startingBounds.width - deltaX >		    parentBounds.width) {		  deltaX = startingBounds.x + startingBounds.width -		    parentBounds.width;		}		newW = startingBounds.width - deltaX;		newH = startingBounds.height;                break;            case SOUTH_EAST:     		if(startingBounds.width - deltaX < min.width)		    deltaX = startingBounds.width - min.width;		else if(startingBounds.width - deltaX > max.width)		    deltaX = -(max.width - startingBounds.width);		if (startingBounds.x + startingBounds.width - deltaX >		    parentBounds.width) {		  deltaX = startingBounds.x + startingBounds.width -		    parentBounds.width;		}		if(startingBounds.height - deltaY < min.height)		    deltaY = startingBounds.height - min.height;		else if(startingBounds.height - deltaY > max.height)		    deltaY = -(max.height - startingBounds.height);		if (startingBounds.y + startingBounds.height - deltaY >		     parentBounds.height) {		  deltaY = startingBounds.y + startingBounds.height -		    parentBounds.height ;		}					newW = startingBounds.width - deltaX;		newH = startingBounds.height - deltaY;                break;            case SOUTH:      		if(startingBounds.height - deltaY < min.height)		    deltaY = startingBounds.height - min.height;		else if(startingBounds.height - deltaY > max.height)		    deltaY = -(max.height - startingBounds.height);		if (startingBounds.y + startingBounds.height - deltaY >		     parentBounds.height) {		  deltaY = startingBounds.y + startingBounds.height -		    parentBounds.height ;		} 		newW = startingBounds.width;		newH = startingBounds.height - deltaY;                break;            case SOUTH_WEST:		if(startingBounds.height - deltaY < min.height)		    deltaY = startingBounds.height - min.height;		else if(startingBounds.height - deltaY > max.height)		    deltaY = -(max.height - startingBounds.height);		if (startingBounds.y + startingBounds.height - deltaY >		     parentBounds.height) {		  deltaY = startingBounds.y + startingBounds.height -		    parentBounds.height ;		}		if(startingBounds.width + deltaX < min.width)		    deltaX = -(startingBounds.width - min.width);		else if(startingBounds.width + deltaX > max.width)		    deltaX = max.width - startingBounds.width;		if (startingBounds.x - deltaX < 0) {		  deltaX = startingBounds.x;		}		newX = startingBounds.x - deltaX;		newY = startingBounds.y;		newW = startingBounds.width + deltaX;		newH = startingBounds.height - deltaY;                break;            case WEST:      		if(startingBounds.width + deltaX < min.width)		    deltaX = -(startingBounds.width - min.width);		else if(startingBounds.width + deltaX > max.width)		    deltaX = max.width - startingBounds.width;		if (startingBounds.x - deltaX < 0) {		  deltaX = startingBounds.x;		}		newX = startingBounds.x - deltaX;		newY = startingBounds.y;		newW = startingBounds.width + deltaX;		newH = startingBounds.height;                break;            case NORTH_WEST:     		if(startingBounds.width + deltaX < min.width)		    deltaX = -(startingBounds.width - min.width);		else if(startingBounds.width + deltaX > max.width)		    deltaX = max.width - startingBounds.width;		if (startingBounds.x - deltaX < 0) {		  deltaX = startingBounds.x;		}		if(startingBounds.height + deltaY < min.height)		    deltaY = -(startingBounds.height - min.height);		else if(startingBounds.height + deltaY > max.height)		    deltaY = max.height - startingBounds.height;		if (startingBounds.y - deltaY < 0) {deltaY = startingBounds.y;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -