📄 jinternalframe.java
字号:
protected boolean rootPaneCheckingEnabled = false; /** Whether the JInternalFrame is resizable. */ protected boolean resizable; /** * The JDesktopIcon that represents the JInternalFrame while it is * iconified. */ protected JDesktopIcon desktopIcon; /** The icon used in the JMenuBar in the TitlePane. */ protected Icon frameIcon; /** The rootPane of the JInternalFrame. */ protected JRootPane rootPane; /** The title on the TitlePane of the JInternalFrame. */ protected String title; /** The bounds of the JInternalFrame before it was maximized. */ private transient Rectangle storedBounds; /** The Component that receives focus by default. */ private transient Component defaultFocus; /** The default close action taken, */ private transient int defaultCloseOperation = DISPOSE_ON_CLOSE; /** Whether the JInternalFrame has become visible for the very first time. */ private transient boolean isFirstTimeVisible = true; /** * Whether the JInternalFrame is in the transition from being a maximized * frame back to a regular sized frame. */ private transient boolean maxTransition = false; /** DOCUMENT ME! */ private transient boolean wasIcon = false; /** * Creates a new JInternalFrame object that has no title, and is * non-resizable, non-maximizable, non-iconifiable, and non-closable. */ public JInternalFrame() { this(null, false, false, false, false); } /** * Creates a new JInternalFrame object with the given title and is * non-resizable, non-maximizable, non-iconifiable, and non-closable. * * @param title The title displayed in the JInternalFrame. */ public JInternalFrame(String title) { this(title, false, false, false, false); } /** * Creates a new JInternalFrame object with the given title and resizable * properties. The JInternalFrame is non-maximizable, non-iconifiable, and * non-closable. * * @param title The title displayed in the JInternalFrame. * @param resizable Whether the JInternalFrame is resizable. */ public JInternalFrame(String title, boolean resizable) { this(title, resizable, false, false, false); } /** * Creates a new JInternalFrame object with the given title, resizable, and * closable properties. The JInternalFrame is non-maximizable and * non-iconifiable. * * @param title The title displayed in the JInternalFrame. * @param resizable Whether the JInternalFrame is resizable. * @param closable Whether the JInternalFrame is closable. */ public JInternalFrame(String title, boolean resizable, boolean closable) { this(title, resizable, closable, false, false); } /** * Creates a new JInternalFrame object with the given title, resizable, * closable and maximizable properties. The JInternalFrame is * non-iconifiable. * * @param title The title displayed in the JInternalFrame. * @param resizable Whether the JInternalFrame is resizable. * @param closable Whether the JInternalFrame is closable. * @param maximizable Whether the JInternalFrame is maximizable. */ public JInternalFrame(String title, boolean resizable, boolean closable, boolean maximizable) { this(title, resizable, closable, maximizable, false); } /** * Creates a new JInternalFrame object with the given title, resizable, * closable, maximizable and iconifiable properties. * * @param title The title displayed in the JInternalFrame. * @param resizable Whether the JInternalFrame is resizable. * @param closable Whether the JInternalFrame is closable. * @param maximizable Whether the JInternalFrame is maximizable. * @param iconifiable Whether the JInternalFrame is iconifiable. */ public JInternalFrame(String title, boolean resizable, boolean closable, boolean maximizable, boolean iconifiable) { this.title = title; this.resizable = resizable; this.closable = closable; this.maximizable = maximizable; this.iconable = iconifiable; storedBounds = new Rectangle(); setRootPane(createRootPane()); updateUI(); setRootPaneCheckingEnabled(true); // Done the init stage, now adds go to content pane. } /** * This method adds Components to this Container. For JInternalFrames, * instead of calling add directly on the JInternalFrame, it should be * called with JInternalFrame.getContentPane().add. If root pane checking * is enabled, calling this method will cause an exception to be thrown. * * @param comp The Component to add. * @param constraints The constraints on the Component added. * @param index The position to place the Component. * * @throws Error DOCUMENT ME! */ protected void addImpl(Component comp, Object constraints, int index) { // If we're in the initialization stage use super.add. Here we add the // rootPane as well as the title bar and other stuff. // Otherwise pass the add onto the content pane. if (isRootPaneCheckingEnabled()) getContentPane().add(comp, constraints, index); else super.addImpl(comp,constraints, index); } /** * This method adds an InternalFrameListener to this JInternalFrame. * * @param l The listener to add. */ public void addInternalFrameListener(InternalFrameListener l) { listenerList.add(InternalFrameListener.class, l); } /** * This method is used to create a root pane for the JInternalFrame. This * method is called by the constructors. * * @return A root pane for the JInternalFrame to use. */ protected JRootPane createRootPane() { return new JRootPane(); } /** * This method makes this JInternalFrame invisible, unselected and closed. * If this JInternalFrame is not closed already, it will fire an * INTERNAL_FRAME_CLoSED event. This method is similar to setClosed but it * doesn't give vetoable listeners a chance to veto and it will not fire an * INTERNAL_FRAME_CLOSING event. */ public void dispose() { hide(); JDesktopPane pane = getDesktopPane(); if (pane != null) pane.setSelectedFrame(null); else { try { setSelected(false); } catch (PropertyVetoException e) { // Do nothing if they don't want to be unselected. } } isClosed = true; fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED); removeNotify(); } /** * This method is used for closing this JInternalFrame. It fires an * INTERNAL_FRAME_CLOSING event and then performs the action specified by * the default close operation. */ public void doDefaultCloseAction() { fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING); switch (getDefaultCloseOperation()) { case HIDE_ON_CLOSE: hide(); break; case DISPOSE_ON_CLOSE: dispose(); break; } } /** * This method fires an InternalFrameEvent to the listeners. * * @param id The type of event being fired. See InternalFrameEvent. */ protected void fireInternalFrameEvent(int id) { Object[] ifListeners = listenerList.getListenerList(); InternalFrameEvent evt = new InternalFrameEvent(this, id); switch (id) { case InternalFrameEvent.INTERNAL_FRAME_CLOSING: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameClosing(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameActivated(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_CLOSED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]).internalFrameClosed(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameDeactivated(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameDeiconified(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_ICONIFIED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]) .internalFrameIconified(evt); } break; case InternalFrameEvent.INTERNAL_FRAME_OPENED: for (int i = ifListeners.length - 2; i >= 0; i -= 2) { if (ifListeners[i] == InternalFrameListener.class) ((InternalFrameListener) ifListeners[i + 1]).internalFrameOpened(evt); } break; } } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public AccessibleContext getAccessibleContext() { if (accessibleContext == null) accessibleContext = new AccessibleJInternalFrame(); return accessibleContext; } /** * This method returns the Content Pane for this JInternalFrame. * * @return The Content Pane for this JInternalFrame. */ public Container getContentPane() { return getRootPane().getContentPane(); } /** * This method returns the default action taken when this JInternalFrame is * closed. * * @return The default action taken when this JInternalFrame is closed. */ public int getDefaultCloseOperation() { return defaultCloseOperation; } /** * This method returns the JDesktopIcon that represents this JInternalFrame * while it is iconified. * * @return The JDesktopIcon that represents this JInternalFrame while it is * iconified. */ public JDesktopIcon getDesktopIcon() { if (desktopIcon == null) desktopIcon = new JDesktopIcon(this); return desktopIcon; } /** * This method searches this JInternalFrame ancestors for an instance of * JDesktopPane. If one is found, it is returned. If none is found, then it * will search the JDesktopIcon for a JDesktopPane. * * @return The JDesktopPane that this JInternalFrame belongs to. */ public JDesktopPane getDesktopPane() { JDesktopPane value = (JDesktopPane) SwingUtilities.getAncestorOfClass(JDesktopPane.class, this); if (value == null && desktopIcon != null) value = desktopIcon.getDesktopPane(); return value; } /** * This method returns null because this must always be the root of a focus * traversal. * * @return always null * * @since 1.4 */ public final Container getFocusCycleRootAncestor() { // as defined. return null; } /** * This method returns the child Component that will receive focus if this * JInternalFrame is selected. * * @return The child Component that will receive focus. */ public Component getFocusOwner() { if (isSelected()) { Component focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); if (SwingUtilities.isDescendingFrom(focus, this)) { defaultFocus = focus; return focus; } } return null; } /** * This method returns the Frame Icon (the icon used in the JInternalFrame * TitlePane and iconified frame). * * @return The Frame Icon. */ public Icon getFrameIcon() { return frameIcon; } /** * This method returns the Glass Pane used with this JInternalFrame. * * @return The Glass Pane used with this JInternalFrame. */ public Component getGlassPane() { return getRootPane().getGlassPane(); } /** * This method returns an array of InternalFrameListeners that are listening * to this JInternalFrame. * * @return An array of InternalFrameListeners that are listening to this * JInternalFrame. */ public InternalFrameListener[] getInternalFrameListeners() { return (InternalFrameListener[]) listenerList.getListeners(InternalFrameListener.class); } /** * This method returns the JMenuBar for this JInternalFrame. * * @return The JMenuBar for this JInternalFrame. */ public JMenuBar getJMenuBar() { return getRootPane().getJMenuBar(); } /** * This method returns the layer that this JInternalFrame resides in. * * @return The layer that this JInternalFrame resides in. */ public int getLayer() { JDesktopPane pane = getDesktopPane(); if (pane != null)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -