Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get instance of Application object? #53

Open
novakmi opened this issue Mar 18, 2017 · 2 comments
Open

How to get instance of Application object? #53

novakmi opened this issue Mar 18, 2017 · 2 comments

Comments

@novakmi
Copy link

novakmi commented Mar 18, 2017

Sometimes it is necessary to have access to the instance of Application. For example to call getHostServices() or getParameters(). Is there any way to do it? Seems like GroovyFX hides this instance completely.

@andreas-oberheim
Copy link

You may just use the closure parameter of type groovyx.javafx.GroovyFX

Sample groovy class:

import static groovyx.javafx.GroovyFX.start

start { app ->

    stage(title: 'GroovyFX web site', width: 500, height: 200, show: true) {
        scene(fill: groovyblue) {
            stackPane {
                button('GroovyFX web site', onAction: {
                    def js = app.hostServices.showDocument('http://groovyfx.org/')
                })
            }
        }
    }
}

@novakmi
Copy link
Author

novakmi commented Jan 9, 2018

Thanks, it works :-) I was not aware app can be added to start closure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants