4 Replies - 278 Views - Last Post: 22 June 2020 - 05:00 AM Rate Topic: -----

#1 hellswindstaff   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 37
  • Joined: 27-February 12

keyword implements

Posted 21 June 2020 - 08:04 AM

class AddInterestListener implements ActionListener
{...}

private void createButton()
{
     button= new JButton("Add Interest");

     ActionListener listener= new AddInterestListener();
     button.addActionListener(listener);
}



What is the relation between the ActionListener interface implemented by AddInterestListener and the ActionListener of the createButton method?

I feel that I may not fully understand the keyword implements, other than in terms of the generalization of the terms "className implements interfaceName".

This post has been edited by hellswindstaff: 21 June 2020 - 08:05 AM


Is This A Good Question/Topic? 0
  • +

Replies To: keyword implements

#2 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 834
  • View blog
  • Posts: 6,437
  • Joined: 25-December 13

Re: keyword implements

Posted 21 June 2020 - 08:12 AM

Surely Google would return lots of discussions about implements.
If there some you are not able to understand, copy and paste their text here with the questions you have about what it says.
Was This Post Helpful? 0
  • +
  • -

#3 hellswindstaff   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 37
  • Joined: 27-February 12

Re: keyword implements

Posted 21 June 2020 - 06:35 PM

View PostNormR, on 21 June 2020 - 08:12 AM, said:

Surely Google would return lots of discussions about implements.
If there some you are not able to understand, copy and paste their text here with the questions you have about what it says.


I'm actually getting this stuff from a book so I can't copy and paste. Do you recommend against shortening code by using an ellipsis, with what I assume to be relevant information, or just typing out the entire program?
Was This Post Helpful? 0
  • +
  • -

#4 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 1029
  • View blog
  • Posts: 3,959
  • Joined: 13-June 14

Re: keyword implements

Posted 21 June 2020 - 07:49 PM

I'm not sure I understand the question. createButton creates an instance of AddInterestListener and attaches it to the button it creates. I'm not sure what you're not understanding about that or really how it relates to the implements keyword.
Was This Post Helpful? 0
  • +
  • -

#5 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 834
  • View blog
  • Posts: 6,437
  • Joined: 25-December 13

Re: keyword implements

Posted 22 June 2020 - 05:00 AM

Quote

What is the relation between the ActionListener interface implemented by AddInterestListener and the ActionListener of the createButton method?

The AddInterestListener class is an ActionListener. An instance can be used anywhere an ActionListener is required.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1