Websocket 和 Java Swing 前端 [英] Websocket and Java Swing front end
问题描述
让 Websocket 与 Java Swing 前端接口是否可行?如果是这样怎么办?
Is it doable to make Websocket interfaced with Java Swing front end? If so how?
推荐答案
试试我的:
http://github.com/TooTallNate/Java-WebSocket
包含客户端和服务器实现.在example
文件夹中有一个简单的JFrame
子类,名为ChatClient
.查看它的 Swing 参考来源.
Contains a Client and Server implementation. In the example
folder there's a simple JFrame
subclass called ChatClient
. Look at it's source for a Swing reference.
本质上,您只需要继承 net.tootallnate.websocket.WebSocketClient
并实现 onOpen
、onClose
和 onMessage代码> 方法.该类的接口与 HTML5 的 WebSockets API 非常相似.
Essentially you just need to subclass net.tootallnate.websocket.WebSocketClient
and implement the onOpen
, onClose
, and onMessage
methods. The class has an interface very similarly to the WebSockets API for HTML5.
这篇关于Websocket 和 Java Swing 前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!