Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6579871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:57:10+00:00 2026-05-25T15:57:10+00:00

I am working on a swing application which primarily includes a JTree and some

  • 0

I am working on a swing application which primarily includes a JTree and some other components in it. The complete logic behind the UI display is based upon the root node of JTree. It is a nested node with individual custom UserObjects set to each of the child nodes.

I need to preserve the state of my application for which the single nested root node of the JTree should be preserved. I am unable to do so.

class SerializeImpl implements Serializable{

    def doSerialize() throws Exception{
        def root = FeedTree.getInstance().getModel().getRoot()
        def object = new SerializableNode(top:root)
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("new.txt"))
        out.writeObject(object)
    }

    def doDeSerialize(){
        def file = new File('new.txt')
        def serNodeObj
        try{        
            file.withObjectInputStream(getClass().classLoader){ ois ->
                ois.eachObject{ serNodeObj = it }
            }
            return serNodeObj.getValue()
        }
        catch(FileNotFoundException ex){
            return null
        }

    }       

}


class SerializableNode implements Serializable{

    def top

    def getValue(){
        return top
    }

}

class FeedTree extends JTree{

...............
a singleton instance
...............

}

The doSerialize() method is executed first followed by a System.exit(1) and followed by a fresh display of UI which does doDeSerialize().. The doSerialize() method does write something onto the news.txt file but I am not sure if it is serializing the object corrrectly. Moreover the System.exit(1) after serializing doesn’t work.

After a forced Exit (from eclipse console close) the first execution of doDeSerialize() throws the following exception.

Caught: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: groovy.util.slurpersupport.NodeChildren
    at functionalities.SerializeImpl$_doDeSerialize_closure1.doCall(SerializeImpl.groovy:23)
    at functionalities.SerializeImpl.doDeSerialize(SerializeImpl.groovy:22)

I am unable to understand why the serialize is (probably) failing and why the System.exit(1) is not functioning correctly after the serialize. Please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:57:10+00:00Added an answer on May 25, 2026 at 3:57 pm

    look at method invokeLater or better for Serializable for invokeAndWait(), because Swing code must be done on Event Dispatch Thread,

    correct way, create JTree with DefaultTreeModel separatelly, and from your Serializable methods just to add TreeNodes wrapped into invokeLater

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Swing application (currently running on Java 1.6 update 11) which
I'm working with a combobox in a Swing-based application, and I'm having a hard
I have an application that uses Swing. The display I am working on, uses
I am working on a fairly complex Java application using Swing. On some occasions
I'm working on a java SE 1.5+ swing application, in conjunction with others. I'm
I have a really strange issue. I am working on a Java SWING application
I'm working on swing application that relies on an embedded H2 database. Because I
I'm working on Java Swing application with Google Guice as an IOC container. Things
I'm currently working on a GUI based application and am using the code-generation feature
I'm currently working on a small console application. This application is based on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.