I'm trying to set the button text using this code:
public void initialize(URL location, ResourceBundle resources) {
// TODO Auto-generated method stub
//checking to see whether these buttons were loaded from the FXML file
assert fx_btnStart != null : "fx:id=\"fx_btnStart\" was not injected: Check your FXML file 'FX-Timer.fxml'.";
assert fx_btnStop != null : "fx:id=\"fx_btnStop\" INJECTION ERROR";
assert fx_btnHourUp != null : "fx:id=\"fx_btnHourUp\" INJECTION ERROR";
assert fx_btnHourDown != null : "fx:id=\"fx_btnHourDown\" INJECTION ERROR";
assert fx_btnMinuteUp != null : "fx:id=\"fx_btnMinuteUp\" INJECTION ERROR";
assert fx_btnMinuteDown != null : "fx:id=\"fx_btnMinuteDown\" INJECTION ERROR";
//ending of initialization of FXML elements
//set words for buttons yo.
fx_btnHourUp.setText("HELLO");
}
Here's my FXML:
<children>
<Button mnemonicParsing="false" prefHeight="53.0" prefWidth="92.0"
text="Hup" textAlignment="CENTER" alignment="CENTER" id="fx_btnHourUp"/>
<Button mnemonicParsing="false" prefHeight="37.0" prefWidth="92.0"
text="Hdown" GridPane.columnIndex="1" textAlignment="CENTER"
alignment="CENTER" id="fx_btnHourDown" />
<Button mnemonicParsing="false" prefHeight="44.0" prefWidth="92.0"
text="Mup" GridPane.columnIndex="2" textAlignment="CENTER"
alignment="CENTER" id="fx_btnMinuteUp" />
<Button mnemonicParsing="false" prefHeight="39.0" prefWidth="122.0"
text="Mdown" GridPane.columnIndex="3" textAlignment="CENTER"
alignment="CENTER" id="fx_btnMinuteDown" />
</children>
But it won't work I don't really get why, does anyone else know how to set button text using JavaFX? >.>; I feel like JavaFX isn't as straightforward as Swing...but anyways, anyone know what I'm doing wrong? Also, does anyone know any resources to learn FXML I like FXML more than coding it in Java but there doesn't seem to be much on it, am I like the only guy in the world who prefers FXML over JavaFX GUI coding?