Search code examples
netbeans6.8

NetBeans: accessing class from MyAppView.java


When I add an actionperformed event to a button, it generates the TODO section.

However, I would like for it to call a public method defined in MyApp.java, instead of having to define the method inside the MyAppView.java

How can I do this ? Tell MyAppView.java to get the methods and classes from MyApp.java ?


Solution

  • If I understand you correcty:
    MyApp.java should implement ActionListener interface, then when creating button. Add object of the class MyApp to listen for actions on this button.

    button.addActionListener(myApp);