2014-10-07 5 views
2

스킨, 컨트롤 및 비헤이비어 클래스로 사용자 정의 컨트롤을 만들면 Java Scene Builder에서 내 사용자 정의 속성을 표시 할 수 있습니까? 누군가 이미이 작업을 수행했다면 어떻게 설명 할 수 있습니까? 나는 스킨 및 컨트롤 하위 클래스 모두에서 속성을 가지지 만 성공하지는 못합니다.사용자 지정 컨트롤을 사용하여 Java Scene Builder에서 사용자 지정 속성을 볼 수 있습니까?

감사

JEC

편집 1 :

그래서 다른 사람들이 여기에, 함께 따라 할 수는 장면 빌더를 감지 할 수 있었다 '컨트롤'클래스 샘플입니다.

public class DisplayControl extends Control 

{ 개인을 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); 
    } 
} 

}

+0

좋아 나는이 부분적으로 알아 낸 것 같아요. 따라서 'Control'클래스에 속성이 있어야합니다. 'Control'클래스의 jar가 빌드 된 다음 장면 빌더로 가져와야합니다. 그런 다음 '컨트롤'을 배치하면 속성 창이 '사용자 지정'아래에 나열됩니다. 내 경우에는 그 색과 필드는 여전히 편집 할 수 없으므로이 작업을 계속하고 있습니다. – jecjackal

답변

1

은 속성 접근 방법은 standard naming pattern을 수행합니다. 당신이 javafx.scene.paint.Paint보다는 색상의 사용을하면 당신은

public class DisplayControl extends Control { 

// ... 

    public ObjectProperty<Color> backgroundColorProperty() { ... } 
    public Color getBackgroundColor() { ... } 
    public void setBackgroundColor(...) { ...} 
} 
+0

그게 효과가 있어요. SceneBuilder에서 직접 색상을 편집 할 수는 없지만 적어도 거기에서 색상을 편집 할 수는 있습니다. 감사 – jecjackal

1

을 가져야한다, 값이 장면 작성기에서 편집 할 수있을 것입니다

public class DisplayControl extends Control { 

    // ... 

    public ObjectProperty<Paint> backgroundColorProperty() { ... } 
    public final Paint getBackgroundColor() { ... } 
    public final void setBackgroundColor(final Paint color) { ...} 
} 
관련 문제