Forum Stats

  • 3,852,841 Users
  • 2,264,141 Discussions


Solution to JTable SessionStorage warning while program is running

843810 Member Posts: 46,938
edited Jul 7, 2010 1:14AM in Java Desktop Applications
I have a Netbeans developed Desktop Application showing the following warning:
WARNING: No saved state for javax.swing.JTable ...
There is a now locked forum thread on this topic: []

I think this happens if you are using a JTable with no resizable columns. This is what I found digging in the org.jdesktop.application.SessionStorage source code:
When the method is called to save the application state ( the class org.jdesktop.application.SingleFrameApplication calls it during application shutdown),
for each JTable object in the application, the org.jdesktop.application.SessionStorage.TableProperty.getSessionState() method is called to get a org.jdesktop.application.SessionStorage.TableState
object that is supposed to contain the target JTable state information to be saved.
Unfortunately if the target JTable has no resizable columns the getSessionState() method returns null (this is IMHO a bug !) and this produces an inconsistent saved state that when the application is restarted, causes a null to be retrieved as the JTable state to restore, giving the warning message.

The solution is simple: each JTable object with no resizable columns must have no name, i.e.:
If a component has a null name the save state method ignores it and the warning disappears.

Surprisingly enough, this solution is exactly the opposite of the solution proposed in the previous thread.


  • 843810
    843810 Member Posts: 46,938
    the table.setName(null) worked for me but my tables also have table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    I still don't know what's going on but I appreciate the tip. The warnings are now gone.

This discussion has been closed.