我有一个带有场景构建器的 FXML 文件构建,其中包含所需的 fx:ids 和以下控制器:
public class LaunchLogin extends Application{
public static void main (String [] args) {
launch(args);
}
@Override
public void start (Stage primaryStage) throws Exception {
//ResourceLoader rl = ResourceLoader.getInstance();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/gfx/gui/LoginScreenUI.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root);
scene.getStylesheets().add("/gfx/gui/cogfitStyle.css");
primaryStage.setScene(scene);
primaryStage.setTitle ("CogFit");
primaryStage.show();
}
@FXML
Button btn_newUser;
@FXML
Button btn_changePW;
@FXML
Button btn_send;
@FXML
private void test(ActionEvent event)
{
System.out.println("success");
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想向按钮添加动作事件。我怎么做?我真的找不到涉及 FXML 文件的东西。
javafx ×1