Extending classes at runtime
807580Apr 27 2010 — edited Apr 29 2010Hi,
Is there a way to extend a class at runtime? What I'd like to do is the following:
I want to have a tabbed pane component that does not stretch its tabs when there are several lines of tabs. The stretching of the tabs is implemented in the UI component of JTabbedPane - and this depends on the look & feel - it can be MetalTabbedPaneUI, WindowsTabbedPaneUI, etc.
I want to extend the currently-used UI class (which is only known at runtime) with my own class that overrides a single method.
I can extend all those that I currently know and use some mapping from the currently used class to the one extending it - but tomorrow someone may install a new look & feel which uses a different UI component, for which I will not have an extending class.
Therefore, I'd like to find the currently used UI component class and extend it at runtime.
Thanks,
Shlomy