/* * Copyright 2008-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package sample.javafx.java; import griffon.core.artifact.GriffonView; import griffon.inject.MVCMember; import griffon.metadata.ArtifactProviderFor; import javafx.fxml.FXML; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.paint.Color; import javafx.stage.Stage; import org.codehaus.griffon.runtime.javafx.artifact.AbstractJavaFXGriffonView; import javax.annotation.Nonnull; import java.util.Collections; @ArtifactProviderFor(GriffonView.class) public class SampleView extends AbstractJavaFXGriffonView { @MVCMember @Nonnull private SampleController controller; //<1> @MVCMember @Nonnull private SampleModel model; //<1> @FXML private TextField input; //<2> @FXML private Label output; //<2> @Override public void initUI() { Stage stage = (Stage) getApplication() .createApplicationContainer(Collections.<String, Object>emptyMap()); stage.setTitle(getApplication().getConfiguration().getAsString("application.title")); stage.setWidth(400); stage.setHeight(120); stage.setScene(init()); getApplication().getWindowManager().attach("mainWindow", stage); //<3> } // build the UI private Scene init() { Scene scene = new Scene(new Group()); scene.setFill(Color.WHITE); Node node = loadFromFXML(); model.inputProperty().bindBidirectional(input.textProperty()); model.outputProperty().bindBidirectional(output.textProperty()); ((Group) scene.getRoot()).getChildren().addAll(node); connectActions(node, controller); //<4> return scene; } }