• Post Reply Bookmark Topic Watch Topic
  • New Topic

How To Serialize Listeners

 
Randy Miller
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

I am currently working on a project where I am trying to serialize an entire GUI on PC number 1 and restore that exact GUI on PC number 2.
Basically, I already have a prototype to store and restore the GUI, but how can I serialize the Listeners or how can I restore the exact functionality?
Hope,you can help me out!

Greetings,

Randy
 
Greg Charles
Sheriff
Posts: 3010
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm assuming you mean objects that implement java.awt.EventListener. What makes the listeners different from the rest of the GUI? If you make the classes serializable, the listener objects will be serialized the same way a button or list box would be.
 
Randy Miller
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Greg!

That´s EXACTLY what I meant ;)
As far as I know and I tried this quite a lot these days, you can´t serialize Listeners and its functionality.The only way to serialize an object(GUI) so far(that´s what my "researching" says) implementing listeners is to use the key word "transient" in front of the listeners.But by using this key word,the listeners will be deleted and the buttons are practically dead after deserializing the GUI again.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randy Miller wrote:HThe only way to serialize an object(GUI) so far(that´s what my "researching" says) implementing listeners is to use the key word "transient" in front of the listeners..


The keyword "transient" means that the field will not be serialized, so yea, that would deactivate the GUI.
I'd like to know how old the information your research found is. It used to be true that serialization of listeners was frowned upon because Swing was expected to change rapidly. Since you are exchanging listeners between two Java VM's presumably with the same version of AWT/Swing, I would assume it is possible to exchange listeners.
Personally, I think it makes more sense to serialize the GUI state, rather than each GUI object.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!