Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.example
import griffon.core.artifact.GriffonView
import griffon.inject.MVCMember
import griffon.metadata.ArtifactProviderFor
import javafx.collections.FXCollections
import javafx.fxml.FXML
import javafx.scene.control.Button
import javafx.scene.control.Label
import javafx.scene.control.TableView
import javafx.scene.web.WebView
import javax.annotation.Nonnull
import org.codehaus.griffon.runtime.javafx.artifact.AbstractJavaFXGriffonView
@ArtifactProviderFor(GriffonView)
class HomeView extends AbstractJavaFXGriffonView {
@MVCMember @Nonnull
FactoryBuilderSupport builder
@MVCMember @Nonnull
HomeModel model
@FXML private TableView tableView
@FXML private WebView webView
@FXML private Label clickLabel
@FXML private Button countButton
void initUI() {
builder.application(title: application.configuration['application.title'], name: "settingsWindow",
centerOnScreen: true, resizable: false) {
scene {
// Load fxml file by specified path 'griffon-app/resources/views/home.fxml'
def node = loadFromFXML("views/home.fxml")
// Link button actions with the controller actions
connectActions(node, controller)
// Set data to the table view
initTableViewData()
// Load site by url in web view
webView.engine.load("http://griffon-framework.org")
// Bidirectional binding of the label 'clickLabel' with the model property 'clickCount'
clickLabel.textProperty().bindBidirectional(model.clickCountProperty())
// Set custom text to the button, if you want, for example "Count"
countButton.text = application.messageSource.getMessage("home.count.button.label")
// Render fxml view
fxml node
}
}
}
private initTableViewData() {
def languages = ["JavaScript", "Java", "Python", "Ruby", "PHP", "C++", "CSS", "C#", "C", "Go", "Shell",
"Objective-C", "Scala", "Swift", "TypeScript"]
def items = []
languages.eachWithIndex{ String entry, int i ->
items << new Language(i + 1, entry)
}
// Set list to the table view items
tableView.items = FXCollections.observableArrayList(items)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.