Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Serializing Listeners

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Serializing Listeners

    I have an object that extends JFrame and contains a MouseListener and 3 ActionListeners. After I serialize the object and restore the object, none of the listeners respond any more.

    Is there something special that needs to be done with Listeners in order to serialize them?
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Serializing Listeners

    Long story short: the listener implementation that Swing uses is a transient array - in other words the registered listeners for swing components are not serialized. You could try and use a variety of methods to restore these listeners upon reading the object. My .02, but you might want to consider a different method to save things (I would typically discourage one from saving data in this manner - depending upon what you are doing - as other formats are more flexible to changes to the client/GUI without things breaking)
    Last edited by copeg; March 11th, 2011 at 09:42 PM.

Similar Threads

  1. Mouse Listeners
    By newbie in forum AWT / Java Swing
    Replies: 2
    Last Post: November 27th, 2010, 11:08 PM
  2. Action Listeners and Key Listeners Help
    By xctive in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 18th, 2010, 09:27 AM
  3. Listeners, CopyOnWriteArrayList and removals
    By Richard in forum Collections and Generics
    Replies: 2
    Last Post: August 5th, 2010, 02:12 PM
  4. Menu Event Listeners
    By Gondee in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 16th, 2010, 03:08 PM