< prev index next >

src/java.desktop/share/classes/javax/swing/CellRendererPane.java

Print this page




  41  * here's how CellRendererPane is used in the code the paints each row
  42  * in a JList:
  43  * <pre>
  44  *   cellRendererPane = new CellRendererPane();
  45  *   ...
  46  *   Component rendererComponent = renderer.getListCellRendererComponent();
  47  *   renderer.configureListCellRenderer(dataModel.getElementAt(row), row);
  48  *   cellRendererPane.paintComponent(g, rendererComponent, this, x, y, w, h);
  49  * </pre>
  50  * <p>
  51  * A renderer component must override isShowing() and unconditionally return
  52  * true to work correctly because the Swing paint does nothing for components
  53  * with isShowing false.
  54  * <p>
  55  * <strong>Warning:</strong>
  56  * Serialized objects of this class will not be compatible with
  57  * future Swing releases. The current serialization support is
  58  * appropriate for short term storage or RMI between applications running
  59  * the same version of Swing.  As of 1.4, support for long term storage
  60  * of all JavaBeans&trade;
  61  * has been added to the <code>java.beans</code> package.
  62  * Please see {@link java.beans.XMLEncoder}.
  63  *
  64  * @author Hans Muller
  65  * @since 1.2
  66  */
  67 @SuppressWarnings("serial") // Same-version serialization only
  68 public class CellRendererPane extends Container implements Accessible
  69 {
  70     /**
  71      * Construct a CellRendererPane object.
  72      */
  73     public CellRendererPane() {
  74         super();
  75         setLayout(null);
  76         setVisible(false);
  77     }
  78 
  79     /**
  80      * Overridden to avoid propagating a invalidate up the tree when the
  81      * cell renderer child is configured.


 224 
 225 
 226     /**
 227      * Gets the AccessibleContext associated with this CellRendererPane.
 228      * For CellRendererPanes, the AccessibleContext takes the form of an
 229      * AccessibleCellRendererPane.
 230      * A new AccessibleCellRendererPane instance is created if necessary.
 231      *
 232      * @return an AccessibleCellRendererPane that serves as the
 233      *         AccessibleContext of this CellRendererPane
 234      */
 235     public AccessibleContext getAccessibleContext() {
 236         if (accessibleContext == null) {
 237             accessibleContext = new AccessibleCellRendererPane();
 238         }
 239         return accessibleContext;
 240     }
 241 
 242     /**
 243      * This class implements accessibility support for the
 244      * <code>CellRendererPane</code> class.
 245      */
 246     protected class AccessibleCellRendererPane extends AccessibleAWTContainer {
 247         // AccessibleContext methods
 248         //
 249         /**
 250          * Get the role of this object.
 251          *
 252          * @return an instance of AccessibleRole describing the role of the
 253          * object
 254          * @see AccessibleRole
 255          */
 256         public AccessibleRole getAccessibleRole() {
 257             return AccessibleRole.PANEL;
 258         }
 259     } // inner class AccessibleCellRendererPane
 260 }


  41  * here's how CellRendererPane is used in the code the paints each row
  42  * in a JList:
  43  * <pre>
  44  *   cellRendererPane = new CellRendererPane();
  45  *   ...
  46  *   Component rendererComponent = renderer.getListCellRendererComponent();
  47  *   renderer.configureListCellRenderer(dataModel.getElementAt(row), row);
  48  *   cellRendererPane.paintComponent(g, rendererComponent, this, x, y, w, h);
  49  * </pre>
  50  * <p>
  51  * A renderer component must override isShowing() and unconditionally return
  52  * true to work correctly because the Swing paint does nothing for components
  53  * with isShowing false.
  54  * <p>
  55  * <strong>Warning:</strong>
  56  * Serialized objects of this class will not be compatible with
  57  * future Swing releases. The current serialization support is
  58  * appropriate for short term storage or RMI between applications running
  59  * the same version of Swing.  As of 1.4, support for long term storage
  60  * of all JavaBeans&trade;
  61  * has been added to the {@code java.beans} package.
  62  * Please see {@link java.beans.XMLEncoder}.
  63  *
  64  * @author Hans Muller
  65  * @since 1.2
  66  */
  67 @SuppressWarnings("serial") // Same-version serialization only
  68 public class CellRendererPane extends Container implements Accessible
  69 {
  70     /**
  71      * Construct a CellRendererPane object.
  72      */
  73     public CellRendererPane() {
  74         super();
  75         setLayout(null);
  76         setVisible(false);
  77     }
  78 
  79     /**
  80      * Overridden to avoid propagating a invalidate up the tree when the
  81      * cell renderer child is configured.


 224 
 225 
 226     /**
 227      * Gets the AccessibleContext associated with this CellRendererPane.
 228      * For CellRendererPanes, the AccessibleContext takes the form of an
 229      * AccessibleCellRendererPane.
 230      * A new AccessibleCellRendererPane instance is created if necessary.
 231      *
 232      * @return an AccessibleCellRendererPane that serves as the
 233      *         AccessibleContext of this CellRendererPane
 234      */
 235     public AccessibleContext getAccessibleContext() {
 236         if (accessibleContext == null) {
 237             accessibleContext = new AccessibleCellRendererPane();
 238         }
 239         return accessibleContext;
 240     }
 241 
 242     /**
 243      * This class implements accessibility support for the
 244      * {@code CellRendererPane} class.
 245      */
 246     protected class AccessibleCellRendererPane extends AccessibleAWTContainer {
 247         // AccessibleContext methods
 248         //
 249         /**
 250          * Get the role of this object.
 251          *
 252          * @return an instance of AccessibleRole describing the role of the
 253          * object
 254          * @see AccessibleRole
 255          */
 256         public AccessibleRole getAccessibleRole() {
 257             return AccessibleRole.PANEL;
 258         }
 259     } // inner class AccessibleCellRendererPane
 260 }
< prev index next >