I am making an applet in which people have to enter a 4-number pincode so that they can withdraw a sum of money. However, the withdraw button is deactivated by default, and is only activated when a single code is entered in the pin textfield. What would be the best way to do this?
Java: How to activate a button only if a textfield has a specific value?
427 Views Asked by Niels van 't Riet At
2
There are 2 best solutions below
0

You need to create a Listener and attach it to the TextField. The Listener will fire e very time the contents of the TextField changes. Have the Listener test the contents of the TextField, and if it is correct activate the Button.
Documentation of TextField should give you everything you need to know.
DJClayworth is right on the money.
If you need a concrete example using pure AWT, here it is: