hello friends,

I am making a GUI for a certain fill up form using netbeans..here I need disable a "next" button until all the text fields are filled up...I have tried writing a method that which is called during every keypress event in a text box that checks whether the rest of the text boxes are non empty and the status of the text box from which the key press event came from and then enables the button.but this method gets a bit messy since it has to look for too many conditions to get around the problem of user pressing unnecessary keys (such as backspace,space,arrow keys etc...)....is there any other way of solving this problem.


6 Years
Discussion Span
Last Post by javaAddict

After a quick look at the API of the JTextField, (which you should always read whenever you have a problem), I found this method:
It is inherited by the super class: JTextComponent.

I have never used it, but I believe that you should try to add an InputMethodListener to all of your TextFields. If you do that and implement the method: inputMethodTextChanged of the InputMethodListener interface, that method will be called whenever you change the text of your fields. So just take the text entered from the event argument and check the text field has any.

Try to experiment by adding System.out.printlns to your code.

The inputMethodTextChanged takes as argument a InputMethodEvent. Try to make changes to a field that has that listener and then print that event and see if you can find something that you can use

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.