如果我使用Skin,Control和Behavior类创建自定义控件,是否可以在Java Scene Builder中显示我的自定义属性?如果有人已经这样做了,你能解释一下吗?我在Skin和Control子类中都有属性,但没有成功。您是否可以在具有自定义控件的Java Scene Builder中看到自定义属性?
感谢
JEC
编辑1:
,以便其他人可以按照沿,这里是一个样本 '控制' 类场景生成器能够检测。
public class DisplayControl extends Control
private ObjectProperty m_BackgroundColor;
public DisplayControl()
{
m_Skin = new DisplaySkin(this);
m_BackgroundColor = new SimpleObjectProperty<>(new Color(0.5,
0.5,
0.5,
1));
setSkin(m_Skin);
}
public ObjectProperty<Color> backgroundColor()
{
return m_BackgroundColor;
}
/**
* @return the m_BackgroundColor
*/
public Color getBackgroundColor()
{
return m_BackgroundColor.get();
}
/**
* @param BackgroundColor the BackgroundColor to set
*/
public void setBackgroundColor(Color backgroundColor)
{
if (backgroundColor != m_BackgroundColor.get())
{
m_BackgroundColor.set(backgroundColor);
m_Skin.setBackgroundColor(backgroundColor);
}
}
}
好吧,我想我有这部分想通了。所以你需要在'Control'类中拥有这个属性。确保'Control'类的jar已构建,然后导入到Scene Builder中。然后,在放置“控制”后,属性将在“属性”窗口的“自定义”下列出。在我的情况下,它的颜色和字段仍然是不可编辑的,所以我仍在处理这个问题。 – jecjackal 2014-10-07 22:54:34