javax.swing

Class CellRendererPane

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

    public class CellRendererPane
    extends Container
    implements Accessible
    This class is inserted in between cell renderers and the components that use them. It just exists to thwart the repaint() and invalidate() methods which would otherwise propagate up the tree when the renderer was configured. It's used by the implementations of JTable, JTree, and JList. For example, here's how CellRendererPane is used in the code the paints each row in a JList:
       cellRendererPane = new CellRendererPane();
       ...
       Component rendererComponent = renderer.getListCellRendererComponent();
       renderer.configureListCellRenderer(dataModel.getElementAt(row), row);
       cellRendererPane.paintComponent(g, rendererComponent, this, x, y, w, h);
     

    A renderer component must override isShowing() and unconditionally return true to work correctly because the Swing paint does nothing for components with isShowing false.

    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.

    • Constructor Detail

      • CellRendererPane

        public CellRendererPane()
        Construct a CellRendererPane object.
    • Method Detail

      • paintComponent

        public void paintComponent(Graphics g,
                          Component c,
                          Container p,
                          int x,
                          int y,
                          int w,
                          int h,
                          boolean shouldValidate)
        Paint a cell renderer component c on graphics object g. Before the component is drawn it's reparented to this (if that's necessary), it's bounds are set to w,h and the graphics object is (effectively) translated to x,y. If it's a JComponent, double buffering is temporarily turned off. After the component is painted it's bounds are reset to -w, -h, 0, 0 so that, if it's the last renderer component painted, it will not start consuming input. The Container p is the component we're actually drawing on, typically it's equal to this.getParent(). If shouldValidate is true the component c will be validated before painted.
      • paintComponent

        public void paintComponent(Graphics g,
                          Component c,
                          Container p,
                          int x,
                          int y,
                          int w,
                          int h)
        Calls this.paintComponent(g, c, p, x, y, w, h, false).
      • getAccessibleContext

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

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.

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/cellrendererpane.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, CellRendererPane

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