File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Running a Method inside a ActionListener Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Running a Method inside a ActionListener" Watch "Running a Method inside a ActionListener" New topic
Author

Running a Method inside a ActionListener

Samuel Woodhams
Ranch Hand

Joined: Sep 01, 2009
Posts: 31
hey,

The idea is that i have got an ActionListener that when the user presses on the button it checks a couple of varibles in the main method with if commands and it will eventually find one that is true. At which point it sets a String[]. The String[] is differrent everytime, however the oporation i want preformed on the String[] is the same everytime. i was wonderring if i could refferrence to a method in my code rather then just repeatting the same piece of code 7 times in my project.

this is a cut down version of thye code to show what im trying to achieve


thanks in advance
sam
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

From what I can see, that looks OK -- but why create a new "Genarate" object. Since actionPerformed already belongs to the Genarate class, you can call the method directly on the (implicit) object that's already doing the work; ie.,



In any case, what error are you getting?


[Jess in Action][AskingGoodQuestions]
Samuel Woodhams
Ranch Hand

Joined: Sep 01, 2009
Posts: 31
Thankyou that worked perfectly :-D
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Running a Method inside a ActionListener