You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by richardba <ri...@gmail.com> on 2016/05/04 19:51:51 UTC

Formatting input text field using Griffon and GroovyFX

Hello there, I'm developing a simple application and I came from Java to
Groovy which is way simpler and less verbose, I'm using Griffon/GroovyFX and
gridPane to create a simple GUI app, but I have no idea how to format a
certain textField to only accept numbers, I have tried 

textField(id: 'value', promptText: "Insert value", row: 3, column: 1,
type:BigDecimal)

which does not work, the window is grayed out and no component is rendered
when building and running with gradle, can anyone help me out?



--
View this message in context: http://groovy.329449.n5.nabble.com/Formatting-input-text-field-using-Griffon-and-GroovyFX-tp5732684.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Formatting input text field using Griffon and GroovyFX

Posted by richardba <ri...@gmail.com>.
I don't know if I'm too dumb, but I tried the following


class SimuladorTransacoesView {
@FXBindable BigDecimal senha
    void initUI() {
        builder.application(title:
application.configuration['application.title'],
            sizeToScene: true, centerOnScreen: true, name: 'mainWindow') {
            scene(fill: WHITE, width: 400, height: 300) {
                gridPane(hgap: 5, vgap: 10, padding: 25, alignment:
"top_center") {
                    columnConstraints(minWidth: 50, halignment: "right")
                    columnConstraints(prefWidth: 250, hgrow: 'always')
                    label("Senha", row: 0, column: 0, textFill: black)
                    textField(id: 'senha', text: bind(senha), promptText:
"Digita sua senha", row: 0, column: 1)
                }
            }
      }
}

but it didn't work



--
View this message in context: http://groovy.329449.n5.nabble.com/Formatting-input-text-field-using-Griffon-and-GroovyFX-tp5732684p5732692.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Formatting input text field using Griffon and GroovyFX

Posted by Andres Almiray <aa...@gmail.com>.
There are plenty of examples to be found in the GroovyFX repository, for
example
https://github.com/groovyfx-project/groovyfx/blob/master/src/demo/groovy/BindDemo.groovy

Cheers,
Andres

-------------------------------------------
Java Champion; Groovy Enthusiast
http://jroller.com/aalmiray
http://www.linkedin.com/in/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and
those who don't.
To understand recursion, we must first understand recursion.

On Thu, May 5, 2016 at 2:47 PM, richardba <ri...@gmail.com> wrote:

> and how do I bind a field to a variable?
>
>
>
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/Formatting-input-text-field-using-Griffon-and-GroovyFX-tp5732684p5732690.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>

Re: Formatting input text field using Griffon and GroovyFX

Posted by richardba <ri...@gmail.com>.
and how do I bind a field to a variable?



--
View this message in context: http://groovy.329449.n5.nabble.com/Formatting-input-text-field-using-Griffon-and-GroovyFX-tp5732684p5732690.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Formatting input text field using Griffon and GroovyFX

Posted by richardba <ri...@gmail.com>.
I have managed to format a TextField by actually creating a specialized class
which only receives numbers 


now I add it to the gridPane

NumberTextField password = new NumberTextField(false)
senha.setPromptText("Insert your password")
node(password,row:2,column:1)



--
View this message in context: http://groovy.329449.n5.nabble.com/Formatting-input-text-field-using-Griffon-and-GroovyFX-tp5732684p5732696.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: Formatting input text field using Griffon and GroovyFX

Posted by Andres Almiray <aa...@gmail.com>.
As far as I can tel there's no direct support in JavaFX nor in GroovyFX
that will provide the feature you're looking for.
Alternatives are using a converter, as explained at
http://stackoverflow.com/questions/32173624/javafx-8-binding-with-number-format
or use NumericField from JideFX.

Cheers,
Andres


-------------------------------------------
Java Champion; Groovy Enthusiast
http://jroller.com/aalmiray
http://www.linkedin.com/in/aalmiray
--
What goes up, must come down. Ask any system administrator.
There are 10 types of people in the world: Those who understand binary, and
those who don't.
To understand recursion, we must first understand recursion.

On Wed, May 4, 2016 at 9:51 PM, richardba <ri...@gmail.com> wrote:

> Hello there, I'm developing a simple application and I came from Java to
> Groovy which is way simpler and less verbose, I'm using Griffon/GroovyFX
> and
> gridPane to create a simple GUI app, but I have no idea how to format a
> certain textField to only accept numbers, I have tried
>
> textField(id: 'value', promptText: "Insert value", row: 3, column: 1,
> type:BigDecimal)
>
> which does not work, the window is grayed out and no component is rendered
> when building and running with gradle, can anyone help me out?
>
>
>
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/Formatting-input-text-field-using-Griffon-and-GroovyFX-tp5732684.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>