jinternalframe.java

来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 1,717 行 · 第 1/3 页

JAVA
1,717
字号
      throw new Error("Do not use add() on JInternalPane directly. Use getContentPane().add() instead");    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)      return pane.getLayer(this);    return -1;  }  /**   * This method returns the LayeredPane for this JInternalFrame.   *   * @return The LayeredPane for this JInternalFrame.   */  public JLayeredPane getLayeredPane()  {    return getRootPane().getLayeredPane();  }  /**   * This method is deprecated. This method returns the JMenuBar for this   * JInternalFrame.   *   * @return The JMenuBar for this JInternalFrame.   *   * @deprecated 1.0.3   */  public JMenuBar getMenuBar()  {    return getJMenuBar();  }  /**   * This method returns the child Component that will receive focus when the   * JInternalFrame is selected. If the JInternalFrame is selected, this   * method returns getFocusOwner(). Otherwise, it will return the child   * Component that most recently requested focus. If that is null, then the   * initial focus Component is returned. If that is null, then the default   * focus component is returned.   *   * @return The most recent focus owner.   */  public Component getMostRecentFocusOwner()  {    if (isSelected())      return getFocusOwner();    else      return defaultFocus;  }  /**   * This method returns the bounds of the JInternalFrame if it is not   * maximized. If it is maximized, it returns the bounds of the   * JInternalFrame before it was maximized (the bounds that it will be   * restored to).   *   * @return A Rectangle that contains this JInternalFrame's normal bounds (or   *         just its bounds if it is not maximized).   */  public Rectangle getNormalBounds()  {    if (! isMaximum() && ! maxTransition)      return getBounds();    else      return storedBounds;  }  /**   * This method returns the Root Pane for this JInternalFrame.   *   * @return The Root Pane for this JInternalFrame.   */  public JRootPane getRootPane()  {    return rootPane;  }  /**   * This method sets the title of the JInternalFrame.   *   * @return The String displayed in the TitlePane of this JInternalFrame.   */  public String getTitle()  {    return title;  }  /**   * This method returns the UI used to represent the JInternalFrame.   *   * @return The UI used to represent the JInternalFrame.   */  public InternalFrameUI getUI()  {    return (InternalFrameUI) ui;  }  /**   * This method returns a String identifier that is used to determine which   * class acts as the JInternalFrame's UI.   *   * @return A String identifier to determine a UI class.   */  public String getUIClassID()  {    return "InternalFrameUI";  }  /**   * This method returns null.   *   * @return null.   */  public final String getWarningString()  {    // as defined.    return null;  }  /**   * This method deselects this JInternalFrame and hides it.   */  public void hide()  {    JDesktopPane pane = getDesktopPane();    if (pane != null)      pane.setSelectedFrame(null);    else      {	try	  {	    setSelected(false);	  }	catch (PropertyVetoException e)	  {	    // Do nothing.	  }      }    super.hide();  }  /**   * This method returns whether this JInternalFrame is closable.   *   * @return Whether this JInternalFrame is closable.   */  public boolean isClosable()  {    return closable;  }  /**   * This method returns whether this JInternalFrame has been closed.   *   * @return Whether this JInternalFrame is closed.   */  public boolean isClosed()  {    return isClosed;  }  /**   * This must always return true.   *   * @return always true   *   * @since 1.4   */  public final boolean isFocusCycleRoot()  {    return true;  }  /**   * This method returns whether this JInternalFrame is currently iconified.   *   * @return Whether this JInternalFrame is currently iconified.   */  public boolean isIcon()  {    return isIcon;  }  /**   * This method returns whether the JInternalFrame can be iconified.   *   * @return Whether the JInternalFrame can be iconified.   */  public boolean isIconifiable()  {    return iconable;  }  /**   * This method returns whether this JInternalFrame can be maximized.   *   * @return Whether this JInternalFrame can be maximized.   */  public boolean isMaximizable()  {    return maximizable;  }  /**   * This method returns whether this JInternalFrame is currently maximized.   *   * @return Whether this JInternalFrame is maximized.   */  public boolean isMaximum()  {    return isMaximum;  }  /**   * This method returns whether this JInternalFrame is resizable.   *   * @return Whether this JInternalFrame is resizable.   */  public boolean isResizable()  {    return resizable;  }  /**   * This method returns whether root pane checking is enabled. If root pane   * checking is enabled, then calls to addImpl and setLayout will throw   * exceptions.   *   * @return Whether root pane checking is enabled.   */  protected boolean isRootPaneCheckingEnabled()  {    return rootPaneCheckingEnabled;  }  /**   * This method returns whether this JInternalFrame is selected.   *   * @return Whether this JInternalFrame is selected.   */  public boolean isSelected()  {    return isSelected;  }  /**   * A helper method that moves this JInternalFrame to the back if the parent   * is a JLayeredPane.   */  public void moveToBack()  {    if (getParent() instanceof JLayeredPane)      ((JLayeredPane) getParent()).moveToBack(this);  }  /**   * A helper method that moves this JInternalFrame to the front if the parent   * is a JLayeredPane.   */  public void moveToFront()  {    if (getParent() instanceof JLayeredPane)      ((JLayeredPane) getParent()).moveToFront(this);  }  /**   * This method causes the children of this JInternalFrame to be laid out.   * Before it begins, if this JInternalFrame is an icon, then it will be   * deiconified. If it is maximized, then it will be restored. If either   * operation fails, then this method will return.   */  public void pack()  {    try      {	if (isIcon())	  setIcon(false);	else if (isMaximum())	  setMaximum(false);      }    catch (PropertyVetoException e)      {	// Do nothing if they don't want to be restored first.      }    doLayout();  }

⌨️ 快捷键说明

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