我必须扩展一些代码,它实现了一个使用ActionListener的ActionCommands,以获得有关触发ActionEvent的组件所属对象的更多信息。
同样的代码现在也应该实现FocusListener,所以我需要FocusListener从触发FocusEvent的组件接收类似于ActionCommand的东西。
不幸的是,似乎没有与ActionCommand相同的FocusListener,所以我有点卡住了。如何为我的FocusListener提供类似于ActionCommand的东西?
发布于 2015-04-20 20:26:21
FocusEvent.getComponent()方法检索触发事件的组件。这可能没有直接提供您想要的适当的“命令”,但您可以通过以下方法间接检索与触发事件的组件(例如getComponent方法返回的组件)关联的数据:
https://stackoverflow.com/questions/29757143
复制相似问题