Skip to content

Samples: Supporting classes

Eugene Ryzhikov edited this page Oct 20, 2021 · 1 revision
package com.gluonhq.ignite;

import java.net.URL;

public interface ExampleApp {

    default URL getViewLocation() {
        return getClass().getResource("/com/gluonhq/ignite/view.fxml");
    }
}
package com.gluonhq.ignite;

public class Service {

    public String getText() {
        return "This text is INJECTED";
    }

}
package com.gluonhq.ignite;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;

import javax.inject.Inject;
import java.net.URL;
import java.util.ResourceBundle;

public class ViewController implements Initializable {

    @Inject Service service;
    @FXML Label label;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        label.setText(service.getText());
    }


}
Clone this wiki locally