Table with nested headers

C

Christophe Vanfleteren

Alex said:
Hi,

I am trying to get a table which has nested headers, such as seen here:

http://www2.gol.com/users/tame/swing/examples/JTableExamples1.html

However, when i try and run this demo using JDK 1.3 or 1.4 i get a null
pointer exception.

Does anyone know how to fix these classes, or have alternate code for
having nested/groupable headers?

Thanks,

Alex

Show us the line that gives the nullpointer, and the code where you
initialize the objects used on that line. Otherwise there's not much we can
tell you.
 
A

Alex Brown

I havent written any of my own code, merely downloaded the files found at
the URL below.
http://www2.gol.com/users/tame/swing/examples/JTableExamples1.html

Ive done a bit of checking, and the null object is renderer, which is
declared in the BasicTableHeaderUI, which GroupableTableHeaderUI extends.
Using print i have established that all of the arguments are non-null, but
the renderer is.

The line throwing the error initially is:
Component comp = renderer.getTableCellRendererComponent(header.getTable(),
aColumn.getHeaderValue(), false, false,-1, column);

The error i get is:
java.lang.NullPointerException
at
web.GroupableTableHeaderUI.getHeaderHeight(GroupableTableHeaderUI.java:87)
at
web.GroupableTableHeaderUI.createHeaderSize(GroupableTableHeaderUI.java:113)
at
web.GroupableTableHeaderUI.getPreferredSize(GroupableTableHeaderUI.java:123)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1275)
at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:75)
at java.awt.Container.preferredSize(Container.java:1178)
at java.awt.Container.getPreferredSize(Container.java:1162)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1277)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:702)
at java.awt.Container.layout(Container.java:1020)
at java.awt.Container.doLayout(Container.java:1010)
at java.awt.Container.validateTree(Container.java:1092)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validateTree(Container.java:1099)
at java.awt.Container.validate(Container.java:1067)
at java.awt.Window.show(Window.java:461)
at java.awt.Component.show(Component.java:1133)
at java.awt.Component.setVisible(Component.java:1088)
at web.GroupableHeaderExample.main(GroupableHeaderExample.java:66)

Interestingly enough i have since downloaded more examples from the same
site, and they have also failed to run even when using only the code
downloaded - although the errors produced are different.

Cheers,
Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top