本文整理汇总了Java中com.sun.javafx.scene.control.skin.BehaviorSkinBase类的典型用法代码示例。如果您正苦于以下问题:Java BehaviorSkinBase类的具体用法?Java BehaviorSkinBase怎么用?Java BehaviorSkinBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BehaviorSkinBase类属于com.sun.javafx.scene.control.skin包,在下文中一共展示了BehaviorSkinBase类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inject
import com.sun.javafx.scene.control.skin.BehaviorSkinBase; //导入依赖的package包/类
/**
* Injects the given {@link BehaviorBase behavior} into the given
* {@link BehaviorSkinBase skin} by using reflection.
*
* @param pSkin the {@link BehaviorSkinBase skin}.
* @param pBehavior the {@link BehaviorBase behavior} to inject.
*/
public static void inject(BehaviorSkinBase<?, ?> pSkin, BehaviorBase<?> pBehavior)
{
try
{
Field behaviorField = BehaviorSkinBase.class.getDeclaredField("behavior");
behaviorField.setAccessible(true);
// The old behavior needs to be properly disposed, otherwise
// the new behavior will not work at all.
BehaviorBase<?> oldBehavior = (BehaviorBase<?>)behaviorField.get(pSkin);
oldBehavior.dispose();
behaviorField.set(pSkin, pBehavior);
}
catch (Exception e)
{
// TODO Injection failed, should be inform the user/client?
e.printStackTrace();
}
}