Skip to content

Instantly share code, notes, and snippets.

@npatta01
Created April 23, 2013 07:27
Show Gist options
  • Save npatta01/5441501 to your computer and use it in GitHub Desktop.
Save npatta01/5441501 to your computer and use it in GitHub Desktop.
Sample Controller.java with string property
public class SampleController implements Initializable {
// Define the property
private StringProperty counter = new SimpleStringProperty();
// Define a getter for the property's value
public final String getCounter(){return counter.get();}
// Define a setter for the property's value
public final void setCounter(String value){counter.set(value);}
// Define a getter for the property itself
public StringProperty counterProperty() {return counter;}
private int val=0;
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
val=val+1;
counter.setValue("Counter:" +val);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment