Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

An inheriting question

 
Martin Schneider
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a class which I extend in a two other class. That main-class has three panel and two of them would be same in those child-class but one panel should be modified. I just dont know how to make this happen :|

That doesnt work and I need some help.
Thanks in advance
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I wouldn't subclass JFrame but rather composition. That is:
The main frame uses internally three JPanels. Two of these panels stay always the same. The third panel can be in different states. I don't know what factors affect the state of this panel but maybe you can use some method of constructor argument to control the behaviour of this panel.
Maybe you want to describe the intended behaviour of your gui more closely?
Chantal
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for posting again, but my first sentence was a bit messy. I mean:
I prefer composition to inheritance.
(And for what I know composition points most of the time to the more object oriented solution.)
C
 
Martin Schneider
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, the idea is basically something like this:
I have login window and if login was succesfully main window will open. There is on top of login window and main window some "title panel" which has always the same look (that is diveded in two panels). Hope this cleared a little bit?
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, now I see what you mean.
If you want to use inheritance maybe this sample code helps you:

cheers
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!