Results 1 to 2 of 2
- 01-08-2011, 11:12 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 2
- Rep Power
- 0
Identifying sender on keypress event
I am new to Java and NetBeans. I have written a method to validate the entry in several textfields to make sure that the key pressed is either ENTER, BACKSPACE, DELETE, or the numerals 1-6. I have gone to the Properties of each of those textfields in NetBeans to invoke or call that same method, but I want to make sure that the character typed is not actually entered in the textfield unless it is validated to be one of those keys I listed above. I either want to nullify the entry or reset it to "0" if some other key is pressed. My question is how to have the validation method either nullify the keypress so that nothing is entered or identify the textfield that has the focus and is invoking the event so that I can reset its textfield to "0". thanks.
- 01-08-2011, 04:49 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
Perhaps a DocumentFilter might be more appropriate. See Text Component Features (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)
Similar Threads
-
Sockets - 1 sender, but multiple listening
By Ambergahill in forum New To JavaReplies: 2Last Post: 11-11-2010, 03:27 AM -
Java keypress detection help
By pghazanfari in forum Advanced JavaReplies: 1Last Post: 05-29-2010, 08:30 PM -
help with identifying components of a gui
By jaytee in forum New To JavaReplies: 1Last Post: 03-08-2010, 02:28 AM -
KeyPress for my Button
By bigj in forum New To JavaReplies: 3Last Post: 01-26-2010, 04:27 PM -
in server client remote how to kno the ip of the sender
By Omarero in forum NetworkingReplies: 1Last Post: 06-26-2009, 03:24 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks