Skip to main content

Change in JTable behaviour in Java 6 Update 10

3 replies [Last post]
jimaltio
Offline
Joined: 2008-03-13
Points: 0

I have attached a simple example app for this issue, as it is easier to demonstrate in code than to explain, but I will try and explain anyway:

In Update 10 JTable has changed so that it calls configureEnclosingScrollPane() from updateUI(), which is called from its constructor. This causes the sequence of events below:

Pre Update 10:
Parent.constructor() -> creates JTable subclass -> Parent.constructor() completes -> JTable subclass.configureEnclosingScrollPane() called later.

Update 10:
Parent.constructor() -> creates JTable subclass -> JTable subclass.configureEnclosingScrollPane() called -> parent members are NULL because they are not set until after constructor has finished.

An existing applet of ours uses a member class to override JTable.configureEnclosingScrollPane() and read a member field in the parent class. In previous version JREs this worked, but in Update 10 the call to configureEnclosingScrollPane() from JTable's constructor means that the parent's members are not initialized yet, so when we try to read them they are null, as the stack trace below shows:

java.lang.NullPointerException
at com.altio.examples.applets.JTableTest$SimpleTable.configureEnclosingScrollPane(JTableTest.java:42)
at javax.swing.JTable.updateUI(Unknown Source)
at javax.swing.JTable.(Unknown Source)
at javax.swing.JTable.(Unknown Source)

Now we can obviously work around this issue by changing our code, and we have done so, but the problem is that we have versions of our applet deployed to customers that will not contain this fix, and so if they update to Java 6 Update 10 their application will stop working.

Is there any way to return JTable's behaviour to pre-Update 10, so that configureEnclosingScrollPane() is not called from its constructor?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jimaltio
Offline
Joined: 2008-03-13
Points: 0

Filed as a bug, and was resolved as part of Update 10.

rbair
Offline
Joined: 2003-07-08
Points: 0

Hi,

You should probably file a bug on this issue.

Thanks!
Richard

jimaltio
Offline
Joined: 2008-03-13
Points: 0

Thanks - I've done so and it's been entered as bug id 6687962.

Jim