1
새 컴포넌트에 사용자 정의 액션을 추가하고 싶습니다. 이 작업을 수행하는 방법?JavaFX 2.0 - FXML의 사용자 정의 컴포넌트에 대한 액션 핸들러 생성
예제 코드 :
구성 요소
public class MyCustomComponent extends Region {
public MyCustomComponent(){
super();
this.setOnMouseClicked(new EventHandler<MouseEvent>(){
@Override
public void handle(MouseEvent event) {
/* throw my custom event here and handle it in my FXML controller - but how? :-( */
}
});
}
}
컨트롤러
public class MyController {
@FXML protected void myCustomAction(ActionEvent event) {
// do something
}
}
FXML : 도움
에 대한<BorderPane fx:controller="fxmlexample.MyController"
xmlns:fx="http://javafx.com/fxml">
<top>
<MyCustomComponent onAction="#myCustomAction">
</MyCustomComponent>
</top>
</BorderPane>
들으
! 감사! :-) – fxuser