javax.swing

Class JDesktopPane

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class JDesktopPane
    extends JLayeredPane
    implements Accessible
    A container used to create a multiple-document interface or a virtual desktop. You create JInternalFrame objects and add them to the JDesktopPane. JDesktopPane extends JLayeredPane to manage the potentially overlapping internal frames. It also maintains a reference to an instance of DesktopManager that is set by the UI class for the current look and feel (L&F). Note that JDesktopPane does not support borders.

    This class is normally used as the parent of JInternalFrames to provide a pluggable DesktopManager object to the JInternalFrames. The installUI of the L&F specific implementation is responsible for setting the desktopManager variable appropriately. When the parent of a JInternalFrame is a JDesktopPane, it should delegate most of its behavior to the desktopManager (closing, resizing, etc).

    For further documentation and examples see How to Use Internal Frames, a section in The Java Tutorial.

    Warning: Swing is not thread safe. For more information see Swing's Threading Policy.

    Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

    See Also:
    JInternalFrame, JInternalFrame.JDesktopIcon, DesktopManager
    • Constructor Detail

      • JDesktopPane

        public JDesktopPane()
        Creates a new JDesktopPane.
    • Method Detail

      • getUI

        public DesktopPaneUI getUI()
        Returns the L&F object that renders this component.
        Returns:
        the DesktopPaneUI object that renders this component
      • setDragMode

        public void setDragMode(int dragMode)
        Sets the "dragging style" used by the desktop pane. You may want to change to one mode or another for performance or aesthetic reasons.
        Parameters:
        dragMode - the style of drag to use for items in the Desktop
        Since:
        1.3
        See Also:
        LIVE_DRAG_MODE, OUTLINE_DRAG_MODE
      • getDragMode

        public int getDragMode()
        Gets the current "dragging style" used by the desktop pane.
        Returns:
        either Live_DRAG_MODE or OUTLINE_DRAG_MODE
        Since:
        1.3
        See Also:
        setDragMode(int)
      • getDesktopManager

        public DesktopManager getDesktopManager()
        Returns the DesktopManger that handles desktop-specific UI actions.
      • setDesktopManager

        public void setDesktopManager(DesktopManager d)
        Sets the DesktopManger that will handle desktop-specific UI actions. This may be overridden by LookAndFeel.
        Parameters:
        d - the DesktopManager to use
      • updateUI

        public void updateUI()
        Notification from the UIManager that the L&F has changed. Replaces the current UI object with the latest version from the UIManager.
        Overrides:
        updateUI in class JComponent
        See Also:
        JComponent.updateUI()
      • getAllFrames

        public JInternalFrame[] getAllFrames()
        Returns all JInternalFrames currently displayed in the desktop. Returns iconified frames as well as expanded frames.
        Returns:
        an array of JInternalFrame objects
      • getSelectedFrame

        public JInternalFrame getSelectedFrame()
        Returns the currently active JInternalFrame in this JDesktopPane, or null if no JInternalFrame is currently active.
        Returns:
        the currently active JInternalFrame or null
        Since:
        1.3
      • setSelectedFrame

        public void setSelectedFrame(JInternalFrame f)
        Sets the currently active JInternalFrame in this JDesktopPane. This method is used to bridge the package gap between JDesktopPane and the platform implementation code and should not be called directly. To visually select the frame the client must call JInternalFrame.setSelected(true) to activate the frame.
        Parameters:
        f - the internal frame that's currently selected
        Since:
        1.3
        See Also:
        JInternalFrame.setSelected(boolean)
      • getAllFramesInLayer

        public JInternalFrame[] getAllFramesInLayer(int layer)
        Returns all JInternalFrames currently displayed in the specified layer of the desktop. Returns iconified frames as well expanded frames.
        Parameters:
        layer - an int specifying the desktop layer
        Returns:
        an array of JInternalFrame objects
        See Also:
        JLayeredPane
      • remove

        public void remove(Component comp)
        Removes the specified component from this container. This method also notifies the layout manager to remove the component from this container's layout via the removeLayoutComponent method.

        This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to reflect the changes.

        Overrides:
        remove in class Container
        Parameters:
        comp - the component to be removed
        See Also:
        Container.add(java.awt.Component), Container.invalidate(), Container.validate(), Container.remove(int)
      • selectFrame

        public JInternalFrame selectFrame(boolean forward)
        Selects the next JInternalFrame in this desktop pane.
        Parameters:
        forward - a boolean indicating which direction to select in; true for forward, false for backward
        Returns:
        the JInternalFrame that was selected or null if nothing was selected
        Since:
        1.6
      • addImpl

        protected void addImpl(Component comp,
                   Object constraints,
                   int index)
        Adds the specified component to this container at the specified index. This method also notifies the layout manager to add the component to this container's layout using the specified constraints object via the addLayoutComponent method.

        The constraints are defined by the particular layout manager being used. For example, the BorderLayout class defines five constraints: BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST, BorderLayout.WEST, and BorderLayout.CENTER.

        The GridBagLayout class requires a GridBagConstraints object. Failure to pass the correct type of constraints object results in an IllegalArgumentException.

        If the current layout manager implements LayoutManager2, then LayoutManager2.addLayoutComponent(Component,Object) is invoked on it. If the current layout manager does not implement LayoutManager2, and constraints is a String, then LayoutManager.addLayoutComponent(String,Component) is invoked on it.

        If the component is not an ancestor of this container and has a non-null parent, it is removed from its current parent before it is added to this container.

        This is the method to override if a program needs to track every add request to a container as all other add methods defer to this one. An overriding method should usually include a call to the superclass's version of the method:

        super.addImpl(comp, constraints, index)

        This method changes layout-related information, and therefore, invalidates the component hierarchy. If the container has already been displayed, the hierarchy must be validated thereafter in order to display the added component.

        Overrides:
        addImpl in class JLayeredPane
        Parameters:
        comp - the component to be added
        constraints - an object expressing layout constraints for this component
        index - the position in the container's list at which to insert the component, where -1 means append to the end
        Since:
        1.6
        See Also:
        Container.add(Component), Container.add(Component, int), Container.add(Component, java.lang.Object), Container.invalidate(), LayoutManager, LayoutManager2
      • setComponentZOrder

        public void setComponentZOrder(Component comp,
                              int index)
        Moves the specified component to the specified z-order index in the container. The z-order determines the order that components are painted; the component with the highest z-order paints first and the component with the lowest z-order paints last. Where components overlap, the component with the lower z-order paints over the component with the higher z-order.

        If the component is a child of some other container, it is removed from that container before being added to this container. The important difference between this method and java.awt.Container.add(Component, int) is that this method doesn't call removeNotify on the component while removing it from its previous container unless necessary and when allowed by the underlying native windowing system. This way, if the component has the keyboard focus, it maintains the focus when moved to the new position.

        This property is guaranteed to apply only to lightweight non-Container components.

        This method changes layout-related information, and therefore, invalidates the component hierarchy.

        Note: Not all platforms support changing the z-order of heavyweight components from one container into another without the call to removeNotify. There is no way to detect whether a platform supports this, so developers shouldn't make any assumptions.

        Overrides:
        setComponentZOrder in class Container
        Parameters:
        comp - the component to be moved
        index - the position in the container's list to insert the component, where getComponentCount() appends to the end
        Since:
        1.6
        See Also:
        Container.getComponentZOrder(java.awt.Component), Container.invalidate()
      • paramString

        protected String paramString()
        Returns a string representation of this JDesktopPane. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
        Overrides:
        paramString in class JLayeredPane
        Returns:
        a string representation of this JDesktopPane
      • getAccessibleContext

        public AccessibleContext getAccessibleContext()
        Gets the AccessibleContext associated with this JDesktopPane. For desktop panes, the AccessibleContext takes the form of an AccessibleJDesktopPane. A new AccessibleJDesktopPane instance is created if necessary.
        Specified by:
        getAccessibleContext in interface Accessible
        Overrides:
        getAccessibleContext in class JLayeredPane
        Returns:
        an AccessibleJDesktopPane that serves as the AccessibleContext of this JDesktopPane

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Version en cache

17/11/2024 17:28:48 Cette version de la page est en cache (à la date du 17/11/2024 17:28:48) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.

Document créé le 29/08/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-javax/swing/jdesktoppane.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com, JDesktopPane

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut