Swing - replacement for Qt signal/slots

妖精的绣舞 提交于 2019-12-03 14:44:26
trashgod

If none of the existing EventListener implementations meet your requirements, you can create your own custom event. Every JComponent contains a field of type EventListenerList. You can use the approach outlined in the EventListenerList API to enable your custom JComponent subclass to fire your custom event.

Regarding the signal/slot mechanism, Swing has several ways to implement the observer pattern, outlined here.

This Event Listener tutorial goes through the basics of handling events with listeners.

Connecting your slot for a signal is analogous to adding your EventListener to an event-producing object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!