I wrote this application to test internationalization:
Main.java:
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
FXMLLoader loader = new FXMLLoader();
loader.setResources(ResourceBundle.getBundle("content", Locale.ENGLISH));
Parent root = loader.load(getClass().getResource("sample.fxml").openStream());
primaryStage.setTitle("Hello World");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
sample.fxml:
<AnchorPane prefHeight="400.0" prefWidth="600.0" >
<children>
<Label layoutX="10.0" layoutY="10.0" text="%label" />
</children>
</AnchorPane>
content_en.properties:
label=Hello World
But I can not use FXML for my application. How can I do this without FXML?
If I just add a label and set its text to %label it does not work.