Have you looked at the source for existing renderers?

http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/
http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/TableViewCellRenderer.java
http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ListViewItemRenderer.java
http://svn.apache.org/repos/asf/pivot/trunk/wtk/src/org/apache/pivot/wtk/content/ButtonDataRenderer.java

I think all of them override
org.apache.pivot.wtk.Component.setSize(int, int) as follows.  Notice
the comment.

    @Override
    public void setSize(int width, int height) {
        super.setSize(width, height);

        // Since this component doesn't have a parent, it won't be validated
        // via layout; ensure that it is valid here
        validate();
    }

Chris

On 19 December 2011 18:42, David Delbecq <[email protected]> wrote:
> Hello, i have a Label used as a tableview cell renderer. However, when using
> it, i get a NullPointerException inside the pivot Terra skin. Is there a
> limitation that Label can't be used as cell renderers?
>
>
> the following is BXML code:
> <TableView bxml:id="nodeACLs" tableDataKey="aces">
>             <columns>
>                 <TableView.Column name="principal" headerData="who"
>                     width="1*" >
>                     <cellRenderer>
>                        <ui:PrincipalCellRenderer/>
>                     </cellRenderer>
>                 </TableView.Column>
>
>
> with PrincipalCellRender extending Label
> public class PrincipalCellRenderer extends Label implements
> TableView.CellRenderer{
>
>     @Override
>     public void render(Object row, int rowIndex, int columnIndex,
>             TableView tableView, String columnName, boolean selected,
>             boolean highlighted, boolean disabled) {
>         if (row !=null){
>             DavPrincipal principal = ((DavAce)row).getPrincipal();
>             System.out.println("Setting row to"+principal.getValue());
>             setText(principal.getValue());
>
>         } else
>             setText("");
>
>     }
>
>     @Override
>     public String toString(Object row, String columnName) {
>         if (row !=null){
>             DavPrincipal principal = ((DavAce)row).getPrincipal();
>             return principal.getValue();
>
>         }
>         return "";
>     }
>
>
> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
>     at org.apache.pivot.wtk.skin.LabelSkin.paint(LabelSkin.java:295)
>     at org.apache.pivot.wtk.Component.paint(Component.java:2060)
>     at
> org.apache.pivot.wtk.skin.terra.TerraTableViewSkin.paint(TerraTableViewSkin.java:446)
>     at org.apache.pivot.wtk.Component.paint(Component.java:2060)
>     at org.apache.pivot.wtk.Container.paint(Container.java:410)
>     at org.apache.pivot.wtk.Container.paint(Container.java:410)
>
> Eclipse point me to the following line of LabelSkin for exception
>        if (glyphVectors.getLength() > 0) {
>
>
>
> I solved this by calling manually layout() during render(), but that seems
> curious.
>
> David Delbecq
>

Reply via email to