Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call superclass from subclass

 
nani aman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to ask about passing a value from subclass to super class. I have security class as a super class and integrity class as subclass. The value count generated by checklist. When a button Finish is clicked , i wish to send the value back to Security class to view. How can i do such way?

[code]
public class Security extends JFrame implements ActionListener{
//show the count value from Integrity class
}
public class Integrity extends JFrame implements ActionListener{
public void Count(){
while (!stack.empty()){
stack.pop();
count++;
};
}
}
[\code]

i really wish somebody can help me. Thanks.
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't really have a superclass/subclass relationship here because they both extend JFrame. For Integrity to subclass Security you would have to have Integrity extend Security:

public class Integrity extends Security ...


I think you need to re-think what you're trying to accomplish. By knowing what you're trying to accomplish, the "how" often follows. I'll monitor this thread in case you want to change or refine your answer in light of my response.

Good luck!
[ October 25, 2004: Message edited by: Jeff Bosch ]
 
nani aman
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Jeff, i have very little knowledge about OOP and java but stil want to use it in my project. And the end i came with a lot of inappropriate question here. Thanks for helping me and guide me here.

Thank you a lot.

:roll:
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Nani-

You may want to consider reading the free, downloadable Java tutorial at java.sun.com, especially the threads on objects and oop. I think you'll see Java in a whole new way after reading those, and they don't take long to read.

Good luck.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic