私は完全な初心者で、javafxを使いこなしています。私の最初の試み: [FXML] Javafx:onActionを解決するエラー//ネームスペースにないeventHandler
<?import javafx.scene.web.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<AnchorPane fx:controller="sample.Controller" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" >
<children>
<Button fx:id="but0" layoutX="208.0" layoutY="146.0" mnemonicParsing="false" onAction="#Handle" text="Button" />
</children>
</AnchorPane>
そしてコントローラクラス:次のエラーになり
package sample;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
public class Controller {
@FXML
private Button but0;
@FXML
private void Handle(EventHandler e){
but0.setText("Bla");
}
}
:
エラーのいずれか、onAction = '#ハンドル' を解決しますイベントハンドラがネームスペースにないか、スクリプトにエラーがあります。
私のコントローラクラスは親AnchorPaneのコントローラとして明確に設定されていますが、
ありがとう、働いた。そして、私は規制を満たすために心に留めておきます) –
ニース、私は助けることができてうれしい:) –