• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
John Corkrend
Ranch Hand
Posts: 51
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tony Docherty
Bartender
Posts: 2988
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50189
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be pedantic: the name of that class is inappropriate. A class which implements a Listener should be called XXXListener.
 
Tony Docherty
Bartender
Posts: 2988
59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic