I'm making a windows-run-mobile-concept stock market game using Java, and it's JavaFX libraries, and I'd like to have the form of currency on the lower right of the player's current balance, (in my case USD). The catch with this is, is that whenever the player gains a multiple of a thousand dollars in-game, the player's balance gets larger, which means that the string that holds the player's balance is also larger. This causes the fixed position of the string "USD" in the application to be overlapped by the player's current balance.
I've tried simply forcing the program to move the "USD" symbol whenever the number increases by a multiple of one thousand. This, however, seems highly inefficient and I'm willing to bet that there is a simpler way to do this.
double balance = 12313.00;
DecimalFormat decimalFormat = new DecimalFormat("#,###");
String numberAsString = decimalFormat.format(balance);
Text balanceText = new Text("$" + (numberAsString));
balanceText.setFont(Font.font("Modernist", 72));
balanceText.setFill(Color.web("77e6b3"));
balanceText.setLayoutX(25);
balanceText.setLayoutY(250);
Text currencyText = new Text("USD");
currencyText.setFont(Font.font("Modernist", 36));
currencyText.setFill(Color.web("77e6b3"));
currencyText.setLayoutX(275);
currencyText.setLayoutY(250);