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

📄 basicinternalframeui.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
      }      public void componentShown(ComponentEvent e) {          getHandler().componentShown(e);      }      public void componentHidden(ComponentEvent e) {          getHandler().componentHidden(e);      }    }        protected ComponentListener createComponentListener() {      return getHandler();    }    protected class GlassPaneDispatcher implements MouseInputListener {        // 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.        public void mousePressed(MouseEvent e) {            getHandler().mousePressed(e);        }        public void mouseEntered(MouseEvent e) {            getHandler().mouseEntered(e);        }        public void mouseMoved(MouseEvent e) {            getHandler().mouseMoved(e);        }        public void mouseExited(MouseEvent e) {            getHandler().mouseExited(e);        }        public void mouseClicked(MouseEvent e) {            getHandler().mouseClicked(e);        }        public void mouseReleased(MouseEvent e) {            getHandler().mouseReleased(e);        }        public void mouseDragged(MouseEvent e) {            getHandler().mouseDragged(e);        }    }    protected MouseInputListener createGlassPaneDispatcher() {        return null;    }        protected class BasicInternalFrameListener implements InternalFrameListener    {      // 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.      public void internalFrameClosing(InternalFrameEvent e) {          getHandler().internalFrameClosing(e);      }      public void internalFrameClosed(InternalFrameEvent e) {          getHandler().internalFrameClosed(e);      }      public void internalFrameOpened(InternalFrameEvent e) {          getHandler().internalFrameOpened(e);      }      public void internalFrameIconified(InternalFrameEvent e) {          getHandler().internalFrameIconified(e);      }      public void internalFrameDeiconified(InternalFrameEvent e) {          getHandler().internalFrameDeiconified(e);      }      public void internalFrameActivated(InternalFrameEvent e) {          getHandler().internalFrameActivated(e);      }      public void internalFrameDeactivated(InternalFrameEvent e) {          getHandler().internalFrameDeactivated(e);      }    }        private static boolean isDragging = false;    private class Handler implements ComponentListener, InternalFrameListener,            LayoutManager, MouseInputListener, PropertyChangeListener,            WindowFocusListener, SwingConstants {        public void windowGainedFocus(WindowEvent e) {        }        public void windowLostFocus(WindowEvent e) {            // Cancel a resize which may be in progress, when a            // WINDOW_LOST_FOCUS event occurs, which may be            // caused by an Alt-Tab or a modal dialog popup.            cancelResize();        }        // ComponentHandler methods        /** Invoked when a JInternalFrame's parent's size changes. */        public void componentResized(ComponentEvent e) {            // Get the JInternalFrame's parent container size            Rectangle parentNewBounds = ((Component) e.getSource()).getBounds();            JInternalFrame.JDesktopIcon icon = null;            if (frame != null) {                icon = frame.getDesktopIcon();                // Resize the internal frame if it is maximized and relocate                // the associated icon as well.                if (frame.isMaximum()) {                    frame.setBounds(0, 0, parentNewBounds.width,                        parentNewBounds.height);                }            }            // Relocate the icon base on the new parent bounds.            if (icon != null) {                Rectangle iconBounds = icon.getBounds();                int y = iconBounds.y +                    (parentNewBounds.height - parentBounds.height);                icon.setBounds(iconBounds.x, y,                    iconBounds.width, iconBounds.height);            }            // Update the new parent bounds for next resize.            if (!parentBounds.equals(parentNewBounds)) {                parentBounds = parentNewBounds;            }            // Validate the component tree for this container.            if (frame != null) frame.validate();        }        public void componentMoved(ComponentEvent e) {}        public void componentShown(ComponentEvent e) {}        public void componentHidden(ComponentEvent e) {}        // InternalFrameListener        public void internalFrameClosed(InternalFrameEvent e) {            frame.removeInternalFrameListener(getHandler());        }        public void internalFrameActivated(InternalFrameEvent e) {            if (!isKeyBindingRegistered()){                setKeyBindingRegistered(true);                setupMenuOpenKey();                setupMenuCloseKey();            }            if (isKeyBindingRegistered())                setKeyBindingActive(true);        }        public void internalFrameDeactivated(InternalFrameEvent e) {            setKeyBindingActive(false);        }        public void internalFrameClosing(InternalFrameEvent e) { }        public void internalFrameOpened(InternalFrameEvent e) { }        public void internalFrameIconified(InternalFrameEvent e) { }        public void internalFrameDeiconified(InternalFrameEvent e) { }        // LayoutManager        public void addLayoutComponent(String name, Component c) {}        public void removeLayoutComponent(Component c) {}            public Dimension preferredLayoutSize(Container c)  {            Dimension result;            Insets i = frame.getInsets();                    result = new Dimension(frame.getRootPane().getPreferredSize());            result.width += i.left + i.right;            result.height += i.top + i.bottom;            if(getNorthPane() != null) {                Dimension d = getNorthPane().getPreferredSize();                result.width = Math.max(d.width, result.width);                result.height += d.height;            }            if(getSouthPane() != null) {                Dimension d = getSouthPane().getPreferredSize();                result.width = Math.max(d.width, result.width);                result.height += d.height;            }            if(getEastPane() != null) {                Dimension d = getEastPane().getPreferredSize();                result.width += d.width;                result.height = Math.max(d.height, result.height);            }            if(getWestPane() != null) {                Dimension d = getWestPane().getPreferredSize();                result.width += d.width;                result.height = Math.max(d.height, result.height);            }            return result;        }            public Dimension minimumLayoutSize(Container c) {            // The minimum size of the internal frame only takes into            // account the title pane since you are allowed to resize            // the frames to the point where just the title pane is visible.            Dimension result = new Dimension();            if (getNorthPane() != null &&                getNorthPane() instanceof BasicInternalFrameTitlePane) {                  result = new Dimension(getNorthPane().getMinimumSize());            }            Insets i = frame.getInsets();            result.width += i.left + i.right;            result.height += i.top + i.bottom;                    return result;        }            public void layoutContainer(Container c) {            Insets i = frame.getInsets();            int cx, cy, cw, ch;                        cx = i.left;            cy = i.top;            cw = frame.getWidth() - i.left - i.right;            ch = frame.getHeight() - i.top - i.bottom;                        if(getNorthPane() != null) {                Dimension size = getNorthPane().getPreferredSize();                if (DefaultLookup.getBoolean(frame, BasicInternalFrameUI.this,                          "InternalFrame.layoutTitlePaneAtOrigin", false)) {                    cy = 0;		    ch += i.top;                    getNorthPane().setBounds(0, 0, frame.getWidth(),                                             size.height);                }                else {                    getNorthPane().setBounds(cx, cy, cw, size.height);                }                cy += size.height;                ch -= size.height;            }                if(getSouthPane() != null) {                Dimension size = getSouthPane().getPreferredSize();                getSouthPane().setBounds(cx, frame.getHeight()                                                     - i.bottom - size.height,                                                     cw, size.height);                ch -= size.height;            }                if(getWestPane() != null) {                Dimension size = getWestPane().getPreferredSize();                getWestPane().setBounds(cx, cy, size.width, ch);                cw -= size.width;                cx += size.width;                       }                if(getEastPane() != null) {                Dimension size = getEastPane().getPreferredSize();                getEastPane().setBounds(cw - size.width, cy, size.width, ch);                cw -= size.width;                       }                        if(frame.getRootPane() != null) {                frame.getRootPane().setBounds(cx, cy, cw, ch);            }        }        // MouseInputListener        private Component mouseEventTarget = null;        private Component dragSource = null;        public void mousePressed(MouseEvent e) { }        public void mouseEntered(MouseEvent e) { }        public void mouseMoved(MouseEvent e) { }        public void mouseExited(MouseEvent e) { }        public void mouseClicked(MouseEvent e) { }        public void mouseReleased(MouseEvent e) { }        public void mouseDragged(MouseEvent e) { }        // PropertyChangeListener        public void propertyChange(PropertyChangeEvent evt) {            String prop = (String)evt.getPropertyName();            JInternalFrame f = (JInternalFrame)evt.getSource();            Object newValue = evt.getNewValue();            Object oldValue = evt.getOldValue();            if (JInternalFrame.IS_CLOSED_PROPERTY == prop) {                if (newValue == Boolean.TRUE) {                    // Cancel a resize in progress if the internal frame                    // gets a setClosed(true) or dispose().                    cancelResize();                    if ((frame.getParent() != null) && componentListenerAdded) {                        frame.getParent().removeComponentListener(                                componentListener);                    }                    closeFrame(f);                }            } else if (JInternalFrame.IS_MAXIMUM_PROPERTY == prop) {                if(newValue == Boolean.TRUE) {                    maximizeFrame(f);                } else {                    minimizeFrame(f);                }            } else if(JInternalFrame.IS_ICON_PROPERTY == prop) {                if (newValue == Boolean.TRUE) {                    iconifyFrame(f);                } else {                    deiconifyFrame(f);                }            } else if (JInternalFrame.IS_SELECTED_PROPERTY == prop) {                if (newValue == Boolean.TRUE && oldValue == Boolean.FALSE) {                    activateFrame(f);                } else if (newValue == Boolean.FALSE &&                           oldValue == Boolean.TRUE) {                    deactivateFrame(f);                }            } else if (prop == "ancestor") {                if (newValue == null) {                    // Cancel a resize in progress, if the internal frame                    // gets a remove(), removeNotify() or setIcon(true).                    cancelResize();                }                if (frame.getParent() != null) {                    parentBounds = f.getParent().getBounds();                } else {                    parentBounds = null;                }                if ((frame.getParent() != null) && !componentListenerAdded) {                    f.getParent().addComponentListener(componentListener);                    componentListenerAdded = true;                } else if ((newValue == null) && componentListenerAdded) {                    if (f.getParent() != null) {                        f.getParent().removeComponentListener(                                componentListener);                    }                    componentListenerAdded = false;                }            } else if (JInternalFrame.TITLE_PROPERTY == prop ||                    prop == "closable" || prop == "iconable" ||                    prop == "maximizable") {                Dimension dim = frame.getMinimumSize();                Dimension frame_dim = frame.getSize();                if (dim.width > frame_dim.width) {                    frame.setSize(dim.width, frame_dim.height);                }            }        }    }}

⌨️ 快捷键说明

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