Meaningless Drivel is fun!*
The moose likes Beginning Java and the fly likes Explaining this code(I don't understand it)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Explaining this code(I don Watch "Explaining this code(I don New topic
Author

Explaining this code(I don't understand it)?

John Corkrend
Ranch Hand

Joined: Oct 27, 2012
Posts: 51

Here is some of my code that is functional and does what I want it too, but I don't really understand it.



I don't understand this section of the code, the program is a button is on screen(go) and when it is clicked and error message appears but I don't know how.

Please simplify this for me.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7076
    
  16

John Corkrend wrote:I don't understand this section of the code, the program is a button is on screen(go) and when it is clicked and error message appears but I don't know how.

From what you've supplied, it's difficult to say; but if I were to hazard a guess, I'd say that it's part of the code for a generic ActionListener that supplies a default action.

On the other hand, I could be totally out to lunch.

We need more information...and I don't mean a mind-dump; simply the relevant parts that might help to answer this question.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 1945
    
  28
It's because when you click on a JButton it generates an ActionEvent and calls the actionPerformed(ActionEvent e) method on every object that has registered as an ActionListener to that JButton. In your code you register an instance of handleClass as a ActionListener so it's actionPerformed() method is called which displays a JOptionPane dialog with the message "Error".
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
To be pedantic: the name of that class is inappropriate. A class which implements a Listener should be called XXXListener.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 1945
    
  28
Campbell Ritchie wrote:To be pedantic: the name of that class is inappropriate. A class which implements a Listener should be called XXXListener.

Agreed.
It should also start with an upper case letter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Explaining this code(I don't understand it)?
 
Similar Threads
Overiding and Exceptions
parsing array to method
runtime exception
main method
Checking for Session Timeout