setSkin() is protected (by design), so it is not possible to replace the skin 
of a single instance without subclassing (again, by design). Skins are meant to 
be managed entirely by the component and the theme.

It is possible to call setSkin() directly from within a custom component, 
though I'm not sure that would offer much of an advantage over the approach I 
described below...


On Jun 9, 2010, at 2:26 PM, Chris Bartlett wrote:

> OK, that will achieve what I need to do at the moment.
> 
> Is it possible to set a particular skin for a specific component instance if 
> required?  Or is a component class only ever associated with 0 or 1 skin 
> classes via the theme?
> 
> On Thu, Jun 10, 2010 at 1:10 AM, Greg Brown <[email protected]> wrote:
> Rather than replacing the Sheet skin with a ModifiedTerraSheetSkin, I would 
> suggest that you create a custom Sheet subclass called ModifiedSheet and 
> associate your modified skin class with that class instead. That way, you can 
> instantiate Sheet to get the default sheet skin, and ModifiedSheet to get 
> your custom skin.
> 
> Greg
> 
> On Jun 9, 2010, at 11:48 AM, Chris Bartlett wrote:
> 
> >
> > If I create a custom skin for a standard Pivot component (such as a Sheet), 
> > how do I go about using it?
> >
> > The following works fine, but associates the skin with all instances of 
> > Sheet.
> > Theme.getTheme().set(Sheet.class, ModifiedTerraSheetSkin.class);
> >
> > Is it possible to set a particular skin for a specific component instance?
> >
> > org.apache.pivot.wtk.Component    defines    protected void setSkin(Skin 
> > skin)
> > whose javadoc comment says 'Sets the skin, replacing any previous skin.'
> >
> > However it throws an IllegalStateException if a "Skin is already installed."
> >
> >
> > Regards,
> >
> > Chris
> >
> 
> 

Reply via email to