1 Replies - 461 Views - Last Post: 21 February 2011 - 01:36 PM Rate Topic: -----

#1 Tarsus  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 58
  • Joined: 06-September 10


Posted 21 February 2011 - 12:04 PM


I'm having an issue where I have a save and submit button on a form for a persons details.

I am trying to use abstraction so as I can have buttons doing slightly different things for each concrete class. However, I am having trouble implementing..

I have an action lisener in an abstract class - EmployeeForm (which is declared correctly):

bttnCancelEditMyDetails.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionMyProfile) {

buttonListeners() is an abstract method that I have create using

abstract void buttonListeners();

The two concrete classes are EmployeeTypeOne and EmployeeTypeTwo
public class EmployeeTypeOne extends EmployeeForm
public class EmployeeTypeTwo extends EmployeeForm

.. each of which implement the method
 void buttonListeners(){
// code ommited

I think that I need to instantiate the concrete class but im not sure where to do this.
Can anyone shed some light?


Is This A Good Question/Topic? 0
  • +

Replies To: Abstraction

#2 macosxnerd101  Icon User is offline

  • Games, Graphs, and Auctions
  • member icon

Reputation: 11449
  • View blog
  • Posts: 43,170
  • Joined: 27-December 08

Re: Abstraction

Posted 21 February 2011 - 01:36 PM

Your super class shouldn't know anything about the subclasses, so do not instantiate the subclasses within the super class. Without knowing anything else about your project, the best place to instantiate one or both of your subclasses is probably the main() method to test them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1