简体   繁体   English

如何将动作侦听器指向NetBeans中的其他文件

[英]How to point the action listener to a different file in netbeans

I am using netbeans for my Java swing application. 我正在将netbeans用于我的Java swing应用程序。 I am trying to use mvc pattern. 我正在尝试使用mvc模式。 To do that, I have to set my Controller to be the action listener for many Gui components. 为此,我必须将Controller设置为许多Gui组件的动作侦听器。

With netbeans, if I click on component to add an action listener then it automatically generates the code (the listener). 使用netbeans,如果我单击component来添加操作侦听器,则它将自动生成代码(侦听器)。 How can I use netbeans (through Gui designer) to point the action listener to another class/file? 如何使用Netbeans(通过Gui设计器)将动作侦听器指向另一个类/文件?

Thank you 谢谢

Left click on your component, go to Properties > Events and delete the event you created, accept. 左键单击组件,转到“属性”>“事件”,然后删除您创建的事件,接受。 Then left click again and customize code, there you should be able to add you own action listener. 然后再次单击鼠标左键并自定义代码,您应该可以在其中添加自己的动作侦听器。

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

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