Hari Mohanan wrote:
Now my doubt is, if I inherit MarkPages from MarkAnalysis, can I modify the values of the JFrame 'frame'? That is, the components in the previous class will not be used, instead I only give a new form to the existing JFrame 'frame'. According to my knowledge, 'frame' is an object of class JFrame. So can an object's state be inherited? (Sorry for using confusing sentences, i am a newbie)
No, that is not what inheritance is for, for one, and for two, it simply won't work. Whenever you consider having one class extend another you must ask yourself is the child class a more specialized version of the parent class, for instance, a Dog a more specialized instance of an Animal, but Bark is not a more specialized version of Dog. The next issue is, even if it's not right, will it work? and the answer is no, it will not, since each class will own its own separate JFrame instance that are completely unrelated to each other.
The solution is to pass a reference of one class to the other.