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

📄 basicdesktoppaneui.java

📁 java jdk 1.4的源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	    Dimension size = c.getSize();            Dimension minSize = c.getMinimumSize();	    Point loc = c.getLocation();	    if ("left".equals(command)) {		if (moving) {		    c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);		} else if (resizing) {		    c.setLocation(loc.x - MOVE_RESIZE_INCREMENT, loc.y);		    c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);		}	    } else if ("right".equals(command)) {		if (moving) {		    c.setLocation(loc.x + MOVE_RESIZE_INCREMENT, loc.y);		} else if (resizing) {		    c.setLocation(loc.x, loc.y);		    c.setSize(size.width + MOVE_RESIZE_INCREMENT, size.height);		}	    } else if ("up".equals(command)) {		if (moving) {		    c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);		} else if (resizing) {		    c.setLocation(loc.x, loc.y - MOVE_RESIZE_INCREMENT);		    c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);		}	    } else if ("down".equals(command)) {		if (moving) {		    c.setLocation(loc.x, loc.y + MOVE_RESIZE_INCREMENT);		} else if (resizing) {		    c.setLocation(loc.x, loc.y);		    c.setSize(size.width, size.height + MOVE_RESIZE_INCREMENT);		}	    } else if ("shrinkLeft".equals(command) && resizing) {                if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {                    c.setLocation(loc.x, loc.y);                    c.setSize(size.width - MOVE_RESIZE_INCREMENT, size.height);                } else {                    c.setSize(minSize.width, size.height);                }	    } else if ("shrinkRight".equals(command) && resizing) {                if (minSize.width < (size.width - MOVE_RESIZE_INCREMENT)) {                    c.setLocation(loc.x + MOVE_RESIZE_INCREMENT, loc.y);                    c.setSize(size.width - MOVE_RESIZE_INCREMENT, size.height);                } else {                    c.setLocation(loc.x - minSize.width + size.width , loc.y);                    c.setSize(minSize.width, size.height);                }	    } else if ("shrinkUp".equals(command) && resizing) {                if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {                    c.setLocation(loc.x, loc.y);                    c.setSize(size.width, size.height - MOVE_RESIZE_INCREMENT);                } else {                    c.setSize(size.width, minSize.height);                }	    } else if ("shrinkDown".equals(command) && resizing) {                if (minSize.height < (size.height - MOVE_RESIZE_INCREMENT)) {                    c.setLocation(loc.x, loc.y + MOVE_RESIZE_INCREMENT);                    c.setSize(size.width, size.height - MOVE_RESIZE_INCREMENT);                } else {                    c.setLocation(loc.x, loc.y - minSize.height + size.height);                    c.setSize(size.width, minSize.height);                }            }	}	public boolean isEnabled() { 	    return true;	}    }    /*     * Handles minimizing an internal frame     */    protected class MinimizeAction extends AbstractAction {	public void actionPerformed(ActionEvent e) {	    // minimize the selected frame	    JInternalFrame f = desktop.getSelectedFrame();	    if (f == null) return;	    if (f.isIconifiable() && ! f.isIcon()) {	      try {		f.setIcon(true);	      } catch (PropertyVetoException pve) {	      }	    }	}	public boolean isEnabled() { 	    return true;	}    }    /*     * Handles maximizing an internal frame     */    protected class MaximizeAction extends AbstractAction {	public void actionPerformed(ActionEvent e) {	    // maximize the selected frame	    JInternalFrame f = desktop.getSelectedFrame();	    if (f == null) return;	    if (f.isMaximizable() && !f.isMaximum()) {	      if (f.isIcon()) {		try {		  f.setIcon(false);		  f.setMaximum(true);		} catch (PropertyVetoException pve) {}	      } else		try {		  f.setMaximum(true);		} catch (PropertyVetoException pve) {		}	    }	}	public boolean isEnabled() { 	    return true;      }    }    /*     * Handles navigating to the next internal frame.      */    protected class NavigateAction extends AbstractAction {	public void actionPerformed(ActionEvent e) {	    // navigate to the next frame	    int i = 0;	    verifyFramesCache();	    if (framesCache.size() == 0) return;	    JInternalFrame f = desktop.getSelectedFrame();	    if (f != null) i = framesCache.indexOf(f);	    if (i == -1) {	      /* if the frame is not there, its icon may be */	      i = framesCache.indexOf(f.getDesktopIcon());	      if (i == -1) {		/* error */ return;	      }	    }	    if (++i == framesCache.size()) /* wrap */ i = 0;	    JComponent c = (JComponent) framesCache.elementAt(i);	    if (c instanceof JInternalFrame) {	      try {		((JInternalFrame) c).setSelected(true);		desktopManager.activateFrame((JInternalFrame) c);	      }	      catch (PropertyVetoException pve) {}	    } else {	      /* it had better be an icon! */	      if (!(c instanceof JInternalFrame.JDesktopIcon)){		/* error */		return;	      }	      try {		((JInternalFrame)((JInternalFrame.JDesktopIcon) c).getInternalFrame()).setSelected(true);		desktopManager.activateFrame(((JInternalFrame.JDesktopIcon) c).getInternalFrame());	      }	      catch (PropertyVetoException pve) {}	    }	}	public boolean isEnabled() { 	    return true;	}    }    /*     * Handles navigating to the previous internal frame.      */    private class PreviousAction extends AbstractAction {	public void actionPerformed(ActionEvent e) {	    // navigate to the previous internal frame            int i = 0;	    verifyFramesCache();	    if (framesCache.size() == 0) return;	    JInternalFrame f = desktop.getSelectedFrame();	    if (f != null) i = framesCache.indexOf(f);	    if (i == -1) {	      /* if the frame is not there, its icon may be */	      i = framesCache.indexOf(f.getDesktopIcon());	      if (i == -1) {		/* error */ return;	      }	    }	    if (--i == -1) /* wrap */ i = framesCache.size() - 1;	    JComponent c = (JComponent) framesCache.elementAt(i);	    if (c instanceof JInternalFrame) {	      try {		((JInternalFrame) c).setSelected(true);	      }	      catch (PropertyVetoException pve) {}	    } else {	      /* it had better be an icon! */	      if (!(c instanceof JInternalFrame.JDesktopIcon)){		/* error */		return;	      }	      try {		((JInternalFrame)((JInternalFrame.JDesktopIcon) c).getInternalFrame()).setSelected(true);	      }	      catch (PropertyVetoException pve) {}	    }	}	public boolean isEnabled() { 	    return true;	}    }    /**     * Handles navigating to the component before or after the desktop.     */    private class NavigateOutAction extends AbstractAction {        private boolean moveForward;        public NavigateOutAction(boolean moveForward) {            this.moveForward = moveForward;        }        public void actionPerformed(ActionEvent e) {            Container cycleRoot = desktop.getFocusCycleRootAncestor();            if (cycleRoot != null) {                FocusTraversalPolicy policy =                        cycleRoot.getFocusTraversalPolicy();                if (policy != null && policy instanceof                        SortingFocusTraversalPolicy) {                    SortingFocusTraversalPolicy sPolicy =                            (SortingFocusTraversalPolicy)policy;                    boolean idc = sPolicy.getImplicitDownCycleTraversal();                    try {                        sPolicy.setImplicitDownCycleTraversal(false);                        if (moveForward) {                            KeyboardFocusManager.                                getCurrentKeyboardFocusManager().                                focusNextComponent(desktop);                        } else {                            KeyboardFocusManager.                                getCurrentKeyboardFocusManager().                                focusPreviousComponent(desktop);                        }                    } finally {                        sPolicy.setImplicitDownCycleTraversal(idc);                    }                }            }        }        public boolean isEnabled() {            return true;        }    }    /*     * Verifies the internal frames cache is up to date.     */    private void verifyFramesCache() {	// Need to initialize?	if (framesCache == null) {	    framesCache = new Vector();	}	// Check whether any internal frames have closed in	// which case we have to refresh the frames cache.       	boolean framesHaveClosed = false;	int len = framesCache.size();	for (int i = 0; i < len; i++) {	    JComponent c = 		(JComponent)framesCache.elementAt(i);	    if (c instanceof JInternalFrame) {		JInternalFrame f = (JInternalFrame)c;		if (f.isClosed()) {		    framesHaveClosed = true;		    break;		}	    }	    else if (c instanceof JInternalFrame.JDesktopIcon) {		JInternalFrame.JDesktopIcon icon = 		    (JInternalFrame.JDesktopIcon)c;		JInternalFrame f = (JInternalFrame)icon.getInternalFrame();		if (f.isClosed()) {		    framesHaveClosed = true;		    break;		}	    }	}        	JInternalFrame [] allFrames = desktop.getAllFrames();       	if (framesHaveClosed || allFrames.length != framesCache.size()) {	    // Cache frames starting at the lowest layer.	    framesCache.clear();	    int low = desktop.lowestLayer();	    int high = desktop.highestLayer();	    for (int i = high; i >= low; i--) {		Component [] comp = desktop.getComponentsInLayer(i);		if (comp.length > 0) {		    for (int j = 0; j < comp.length; j++) {			framesCache.addElement(comp[j]);		    }		}	    }       	}    }    // End of accessibility keybindings}

⌨️ 快捷键说明

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