Serializing a JFrame and sending via network

后端 未结 4 928
予麋鹿
予麋鹿 2021-01-24 08:03

What I\'m trying to do is to send a JFrame through sockets. The problem is after I send the form and press the button to view it I get the below exception.

4条回答
  •  鱼传尺愫
    2021-01-24 08:23

    I did it something similar years ago and I ended up sending a JPanel instead that a frame itself.

    I think that the problem in this situation is the fact that the frame is somewhat attached to a Graphics which is not, of course, serialized and sent over network becuse it's really near to the host OS in the implementation (at AWT Window level)

    I suggest you to try sending just a panel (which in the end is just the content pane of the frame that you are trying to send) a try again. If you really need to attach frame properties you could encapsulate them in a custom object and attach them by serialization (eg title or whatever).

提交回复
热议问题