wood burning stoves*
The moose likes JavaFX and the fly likes Form get input data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Form get input data" Watch "Form get input data" New topic
Author

Form get input data

naro pad
Ranch Hand

Joined: May 07, 2008
Posts: 58

Hi,
I am have just started my first javafx application and I have the following easy issue:

I have the following javafx fxml file


Now I want to bind this 4 fields to an object and use this object on the fxml controller class to pass the data entered on the form into the database .I have tried to find related examples on the Internet but without any luck. Can anyone help me.
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

You need to define a controller class. Either by telling the classname in the fxml file or in the loader of your fxml file.
You might want to read fxml manual and fxml tutorial.
If you have any questions don't hesitate to ask.


Please correct my English.
naro pad
Ranch Hand

Joined: May 07, 2008
Posts: 58

I already created my controller class. My problem is how to bind the controls to the object properties.
Manuel Petermann
Ranch Hand

Joined: Jul 19, 2011
Posts: 175

You could add an onAction="#onTextChanged" to your TextFields like this:

and implement those in your controller like:

or you could add the controlls to your controller and add the listener afterwards like:


remember that the field name and the id always needs to be the same.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Form get input data
 
Similar Threads
JSlider issue
Embedding encoded image in .FXML file
javafx 2, layoutx / layouty values
HBox, ChoiceBox and tab-order weirdness
How does JavaFX relate in the WorkPlace.