Websocket 和 Java Swing 前端 [英] Websocket and Java Swing front end

查看:36
本文介绍了Websocket 和 Java Swing 前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让 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 并实现 onOpenonCloseonMessage 方法.该类的接口与 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆