This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am using a document filter to restrict the number of characters allowed in a JTextfield to 2. It works fine when I try to type in data. Here's the code
My program basically allows the user to cycle through a set of data, which is displayed on the JTextField. The problem is that if the length of the data stored in the field is 2, the textfield is not updated with the data which comes next in the cycle. (I used setText to assign the next value). For example, if the set of data is 2,5,23,28,6 , what i am getting as output is 2,5,5,5,6. I suppose this is because the sum of the lengths of the data already in the JTextField and the new data is >2. How can i get it to work properly? I have a feeling that the solution is pretty simple, but cant quite figure it out.