This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I am using NetBeans 5.0.I want to restrict input only to numbers in a JTextField.So, i have created a class called NumbersDocumentFilter that extends from javax.swing.text.DefaultFilter class.I did override the insertString method in its body it wrote the following line: throw new java.lang.RuntimeException();
No thing happens when the user adds text to the txtPortNumber control. One strange note : The netbeans does not recogonize the insertString method i did override as an overriden method from the DocumentFilter class.I have copied the method from the source code of the DocumentFilter class.
If you only want to accept whole numbers (as I guess is true for a port number), consider using a JSpinner instead.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Jul 15, 2006
Thanks a lot. You have saved a lot of work and suffering.