Searching a file with a textfield

Hey guys, so in my game the player has the option to load a game. The player enters the name of their character and then it starts.If I enter the name of the file into the textfield, it does not work.

However, if I press a back button to exit out then return to the screen with the textfield, the textfield is pre filled with the valued I entered and Java will say the file exists. So basically only when the textfield is prefilled will the file exist. Is there anyway to search as you type with t0neg0d gui?

@JacobAmaral said: Hey guys, so in my game the player has the option to load a game. The player enters the name of their character and then it starts.If I enter the name of the file into the textfield, it does not work.

However, if I press a back button to exit out then return to the screen with the textfield, the textfield is pre filled with the valued I entered and Java will say the file exists. So basically only when the textfield is prefilled will the file exist. Is there anyway to search as you type with t0neg0d gui?

This sounds like an issue =)

If you use TextField.getText() when you enter the stringā€¦ and TextField.getText() when you preload it and compare the stringsā€¦ what is the result?

@t0neg0d said: This sounds like an issue =)

If you use TextField.getText() when you enter the stringā€¦ and TextField.getText() when you preload it and compare the stringsā€¦ what is the result?

Got it to work, by putting both the file object and getText() method as a variable in the update method in constantly checks. Previously I had them in onMouseButtonDown.

1 Like