Overwriting add() to make an own subclass of JDialog
Maybe this question is kind of stupid but somehow I am stuck now. I've been doing all kind of GUI related work with Swing. Drawing own components is regular business. However, I wanted to create a subclass of JDialog that looks a bit nicer, however offers the same interface as the original JDialog + some more nice features. For example every of my Dialog instances will have a predefined Ok and Cancel button which are also wired with some key kisteners (Enter triggers predefined Ok-keyaction method stub, Escape another one for cancel).
One thing I also wanted to add, is a common header (like the ones you can see when creating a new class in Eclipse). Now what I did was I made JContentPane of the JDialog layed out with Borderlayout. I then added the header panel to the north, and a body panel to the centre.
Now as I mentioned before, I want to keep the same interface as the original JDialog. So if the user using my component uses MyDialogObject.add(Somecomponent), I want to pass every of those component adds to the body panel added before. I could overwrite all the add() and remove() functions but this will break the initial add of the header panel and the body panel...
Any idea how to do that in the correct way?
Also I have a second question I'm wondering how to do that. As mentioned my extended version adds some components (header, body, two buttons)... this is currently done in the constructor...
However, I want to make this class a prototype for many implementations (just like the original JDialog is a prototype components for a whole lot of specific Dialogs used in different java applications). Thus, the components header, body, buttons will have to be added to the extended prototype of my Dialog even if the user decides to implement his own constructor and overwrites the one of my superclass... So my question is: where to add the components so that the user extending my class is not able to overwrite the part which adds the initial components?
Hope I explained it clearly. If you have any questions (or even better some good advice), please post here :)
Thanks for your help already :D