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

📄 basicinternalframeui.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
                        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 RootPaneContainer) {                    Component glassPane = ((RootPaneContainer)c).getGlassPane();                    glassPane.setVisible(true);                    glassPane.setCursor(s);                } 		getDesktopManager().beginResizingFrame(frame, resizeDir);                resizing = true;                // Add the WindowFocusListener for handling a                // WINDOW_LOST_FOCUS event with a cancelResize().                Window windowAncestor = SwingUtilities.getWindowAncestor(frame);                if (windowAncestor != null) {                    windowAncestor.addWindowFocusListener(                        getWindowFocusListener());                }		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;}		newX = startingBounds.x - deltaX;		newY = startingBounds.y - deltaY;		newW = startingBounds.width + deltaX;		newH = startingBounds.height + deltaY;                break;            default:                return;            }	    getDesktopManager().resizeFrame(frame, newX, newY, newW, newH);	}        public void mouseMoved(MouseEvent e)    {	    if(!frame.isResizable())		return;            if (e.getSource() == frame || e.getSource() == getNorthPane()) {                Insets i = frame.getInsets();                Point ep = new Point(e.getX(), e.getY());                if (e.getSource() == getNorthPane()) {                    Point np = getNorthPane().getLocation();                    ep.x += np.x;                    ep.y += np.y;                }                if(ep.x <= i.left) {                    if(ep.y < resizeCornerSize + i.top)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));                    else if(ep.y > frame.getHeight() - resizeCornerSize - i.bottom)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));                    else                			frame.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));                } else if(ep.x >= frame.getWidth() - i.right) {                    if(e.getY() < resizeCornerSize + i.top)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));                    else if(ep.y > frame.getHeight() - resizeCornerSize - i.bottom)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));                    else                			frame.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));                } else if(ep.y <= i.top) {                    if(ep.x < resizeCornerSize + i.left)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));                    else if(ep.x > frame.getWidth() - resizeCornerSize - i.right)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));                    else                			frame.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));                } else if(ep.y >= frame.getHeight() - i.bottom) {                    if(ep.x < resizeCornerSize + i.left)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));                    else if(ep.x > frame.getWidth() - resizeCornerSize - i.right)			frame.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));                    else                			frame.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));                }		else		    updateFrameCursor();                return;            }	    updateFrameCursor();	}                 public void mouseEntered(MouseEvent e)    {            updateFrameCursor();        }        public void mouseExited(MouseEvent e)    {            updateFrameCursor();	}    };    /// End BorderListener Class    protected class ComponentHandler implements ComponentListener {      // NOTE: This class exists only for backward compatability. All      // its functionality has been moved into Handler. If you need to add      // new functionality add it to the Handler, but make sure this            // class calls into the Handler.      /** Invoked when a JInternalFrame's parent's size changes. */      public void componentResized(ComponentEvent e) {          getHandler().componentResized(e);      }      public void componentMoved(ComponentEvent e) {          getHandler().componentMoved(e);

⌨️ 快捷键说明

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