2013-12-17 3 views
0

궁금한 점 JavaFx에서 텍스트가 이미지 아래에있는 버튼 스타일을 어떻게 달성 할 수 있습니까?이미지가있는 버튼 스타일

나는 많은 노력을했지만 헛된 것이 었습니다. 어떤 도움을 주시면 감사하겠습니다.

enter image description here

답변

4

키가 contentDisplay 속성입니다은 "TOP"로 설정합니다. fxml와

:

<Button contentDisplay="TOP" layoutX="101.0" layoutY="51.0" mnemonicParsing="false" text="Button"> 
    <graphic> 
    <ImageView mouseTransparent="true" pickOnBounds="true" preserveRatio="true"> 
     <image> 
     <Image url="@image.png" preserveRatio="false" smooth="false" /> 
     </image> 
    </ImageView> 
    </graphic> 
</Button> 

또는 CSS :

.your-selector { 
    -fx-content-display: top; 
} 

는 CSS 참조 here을 확인합니다.

2

당신은 간단하게, 단지

Button b = new Button("text", graphics); 
    b.setContentDisplay(ContentDisplay.TOP); 

을 수행하여 멋진 아이콘에 대한 그 달성이 ... FontAwesomeIcoMoon

+0

미안 실수을 downvoted에서 유일한 방법 icone을 포함 http://fxexperience.com/controlsfx/features/에서 좀 걸릴 수 있습니다 I downvote를 취소하는 것이 당신의 포스트를 먼저 편집하도록하는 것입니다 (그냥 점을 추가하십시오). http://meta.stackexchange.com/questions/139949/unable-to-undo-downvote –