Witam mam prostą aplikacje w JavaFx w oparciu o wzorzec MVC, niestety po wcisnieciu przycisku program nic nie wykonuje jaka moze byc tego przyczyna?
Sample.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.control.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<children>
<ButtonBar layoutX="192.0" layoutY="278.0">
<buttons>
<Button fx:id="button" mnemonicParsing="false" text="klikaj" />
</buttons>
</ButtonBar>
<Circle fx:id="kolko" fill="#ff1f1f" layoutX="135.0" layoutY="200.0" radius="57.0" stroke="BLACK" strokeType="INSIDE" />
<TextField fx:id="PoleTekstowe" alignment="CENTER" layoutX="87.0" layoutY="27.0" prefHeight="23.0" prefWidth="401.0>
<font>
<Font size="14.0" />
</font>
</TextField>
<Label fx:id="label" layoutX="235.0" layoutY="169.0" prefHeight="33.0" prefWidth="248.0" />
</children>
</AnchorPane>
SampleController.java
package application;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
public class SampleController {
@FXML
private Button button;
@FXML
private Circle kolko;
@FXML
private TextField PoleTekstowe;
@FXML
private Label label;
public void initialize(URL arg0, ResourceBundle arg1) {
button.setOnAction(new javafx.event.EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
label.setText(PoleTekstowe.getText());
kolko.setFill(Color.GREEN);
}
});
}
}
Main.java
package application;
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.fxml.FXMLLoader;
public class Main extends Application {
@Override
public void start(Stage primaryStage) {
try {
AnchorPane root = (AnchorPane)FXMLLoader.load(getClass().getResource("Sample.fxml"));
Scene scene = new Scene(root,800,600);
scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}