It doesn't look like you are calling setSize() on your renderer anywhere. You'll probably want to do this. You'll probably also want to make sure that your renderer overrides setSize() to call validate(). See the renderers in org.apache.pivot.wtk.content for an example.
On Sep 8, 2011, at 8:40 AM, prophe wrote: > I have another error while creating custom filter. I try to write my own skin > and filter renderer for table filter. As example of code I use > TerraTableViewSkin.class, TableViewCellRenderer.class and TableView.class. I > need to render default text in my filter when it isn't applied... like this: > http://apache-pivot-users.399431.n3.nabble.com/file/n3319533/te.png > > But I have an error in my custom class GridViewFilterSkin.class in this > lines: > > // render filter data > for (int columnIndex = 0, columnCount = columns.getLength(); > columnIndex < > columnCount; columnIndex++) { > TableView.Column column = columns.get(columnIndex); > Object rowData = tableData.get(0); > > for (int filterIndex = 0, filterCount = > filters.getLength(); filterIndex > < filterCount; filterIndex++) { > Filter filter = filters.get(filterIndex); > if > (filter.getColumnName().equals(column.getName())) { > _filter = filter; > break; > } > } > > GridViewFilter.FilterRenderer filterRenderer = > _filter.getFilterRenderer(); > > int columnWidth = columnWidths.get(columnIndex); > > Graphics2D rendererGraphics = (Graphics2D) > graphics.create(columnX, > 0, columnWidth, height); > > filterRenderer.render(_filter, columnIndex, tableView); > > filterRenderer.paint(rendererGraphics); > > rendererGraphics.dispose(); > > columnX += columnWidth + 1; > } > > in method paint(Graphics2D graphics) in line > filterRenderer.paint(rendererGraphics); and my error is: > > 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 com.custom.skin.GridViewFilterSkin.paint(GridViewFilterSkin.java:192) > 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) > at org.apache.pivot.wtk.Container.paint(Container.java:410) > at org.apache.pivot.wtk.Container.paint(Container.java:410) > at org.apache.pivot.wtk.Container.paint(Container.java:410) > at org.apache.pivot.wtk.Container.paint(Container.java:410) > at > org.apache.pivot.wtk.ApplicationContext$DisplayHost.paintDisplay(ApplicationContext.java:564) > at > org.apache.pivot.wtk.ApplicationContext$DisplayHost.paintVolatileBuffered(ApplicationContext.java:530) > at > org.apache.pivot.wtk.ApplicationContext$DisplayHost.paint(ApplicationContext.java:434) > at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source) > at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source) > at sun.awt.SunGraphicsCallback.runComponents(Unknown Source) > at java.awt.Container.paint(Unknown Source) > at java.awt.Window.paint(Unknown Source) > at sun.awt.RepaintArea.paintComponent(Unknown Source) > at sun.awt.RepaintArea.paint(Unknown Source) > at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) > at sun.awt.windows.WWindowPeer.handleEvent(Unknown Source) > at java.awt.Component.dispatchEventImpl(Unknown Source) > at java.awt.Container.dispatchEventImpl(Unknown Source) > at java.awt.Window.dispatchEventImpl(Unknown Source) > at java.awt.Component.dispatchEvent(Unknown Source) > at java.awt.EventQueue.dispatchEventImpl(Unknown Source) > at java.awt.EventQueue.access$000(Unknown Source) > at java.awt.EventQueue$1.run(Unknown Source) > at java.awt.EventQueue$1.run(Unknown Source) > at java.security.AccessController.doPrivileged(Native Method) > at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown > Source) > at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown > Source) > at java.awt.EventQueue$2.run(Unknown Source) > at java.awt.EventQueue$2.run(Unknown Source) > at java.security.AccessController.doPrivileged(Native Method) > at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown > Source) > at java.awt.EventQueue.dispatchEvent(Unknown Source) > at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) > at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) > at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > at java.awt.EventDispatchThread.run(Unknown Source) > > All my code to test you can find http://perdunov.net/pivotforum.rar here > > if you comment line filterRenderer.paint(rendererGraphics); - you can see > my table rendered. > > ----- > Thank you! > -- > View this message in context: > http://apache-pivot-users.399431.n3.nabble.com/Custom-TableViewFilter-tp3304078p3319533.html > Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
