简体   繁体   English

如何修改一个ActionEvent

[英]How to modify an ActionEvent

I have a class that receives an Actionevent. 我有一个接收Actionevent的类。 I want to modify this event and add some objects to it (if that is possible). 我想修改此事件并向其中添加一些对象(如果可能的话)。 Kinda like how you do with Intents in Android. Kinda喜欢您在Android中使用Intent的方式。 Is this possible or not? 这有可能吗?

To add some background: 要添加一些背景:

The first class receives an actionEvent when a button is clicked, but I want this class to add a string value to the actionEvent and dispatch the event to another class acting as an actionlistener for this class. 第一个类在单击按钮时会收到一个actionEvent,但是我希望该类向actionEvent添加一个字符串值,并将该事件分派给充当该类的动作侦听器的另一个类。 Is this possible or not? 这有可能吗? Would the dispatched event trigger an actionPerformed event? 分派的事件会触发actionPerformed事件吗?

I solved this by merging both classes into one which made it a lot easier by simply setting a variable and call a function to accomplish what I wanted. 我通过将两个类合并为一个类来解决此问题,只需设置一个变量并调用一个函数来完成我想要的操作,就可以轻松得多。 The other solution would have been to create a custom editable event and make both classes receivers of this event, but this is an assignment and I didn't have time to do that 另一个解决方案是创建一个自定义可编辑事件,并使该事件的两个类都成为该事件的接收者,但这是一项任务,我没有时间这样做

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM