I've just come back to a project that I was struggling with before - and I still am. I'm trying to use KeyListener to compare a typed or pressed key, so that if a certain key is pressed, a method is invoked.
I have added KeyListener to 2 text fields, and using the getSource() method, I can at least tell which text field the key stroke occurred in. What I need to be able to do now, is say that if that key stroke = "d" or "D", I want to enter todays date in the text field.
The date part is no problem, but I'm having a heck of a job trying to recognise and compare the pressed key. Am I on the right lines with getKeyChar() or am I going completely wrong?
Any help would be very much appreciated - this is a personal project, not homework or anything. I haven't posted any code because ther than adding the listener to the textfield and invoking the getSource() method, there isn't a lot to see.