TextField Validation for Teleport Feature in Game
Table organization

this.menuTable.setPosition(this.stageWidth/10, this.stageHeight/8);
this.menuTable.setWidth((float)(this.stageWidth * 0.8));
this.menuTable.setHeight((float)(this.stageHeight * 0.6));


I have mentioned before that I do not like this. This is not the "correct" way to setup a table on your screen. When you solve this issue, you will no longer need to pass around stageWidth and stageHeight.

Guess what the magic number is today?

this.menuTable.add("Latitude 0 - 50");
this.menuTable.add("Longitude 0 - 50");


Extract 50 to a static final int constant and use string concatenation to set the string:

this.menuTable.add("Latitude 0 - " + MAX);


processTextField

The first thing that comes to my mind is: If a user enters invalid input, should they then really be teleported?

If I enter the coordinate -42, 1not2a3number4, I would expect an error message, not being teleported to (0, 0). Also remember that users will not be able to see System.out.println output.

That being said, I'd also make some other changes:


Use int instead of Integer for position variable
Instead of if (position &lt; 0) do position = Math.max(0, position);
Instead of if (position &gt;= MAX) do position = Math.min(MAX, position);


The both Math.max and Math.min uses can be put together into:

position = Math.min(MAX, Math.max(0, position));


However, there is a LibGDX method in MathUtils that already does this:

position = MathUtils.clamp(position, 0, MAX);