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>
Thxを
!ありがとう! :-) – fxuser