How can we serialize a Frame, and how can we use that again?

Posted on 2006-03-26
Last Modified: 2012-05-05

 I need to serialize a frame and have to use again it. For that i serialized the frame, but while reading that frame from file, i am getting exception like javax.swing.AbstractButton$ButtonActionPropertyChangeListener; no valid constructor
        at java.beans.PropertyChangeSupport.writeObject(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(

 can you suggest me is there any mistake reading the frame from file.
Question by:krishnasaikarthik
    LVL 30

    Expert Comment

    Why is it necessary for you to serialize the frame? The error is for some anonymous inner class defined inside the AbstractButton class. Looks like you serialized it using a different version of Java and are deserializing it using another - just a guess.
    LVL 35

    Accepted Solution

    To be serializable, ALL classes need to have empty constructors

    The inner class ButtonActionPropertyChangeListener does not have an empty constructor

    Therefore you can't serialize it.

    Try using the XMLEncoder to serialize it if you really need to

    But you're probably better off just writing the data to the disk, and writing a method of reloading the data, rather than trying to serialize the UI components

    LVL 30

    Assisted Solution

    Exactly, you need not serialize the whole frame itself. You can't make changes to the ButtonActionPropertyChangeListener class.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now