Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

identify that event is generated by a Swing JTextField or JTextArea

Status
Not open for further replies.

25884

Programmer
Mar 12, 2001
46
0
0
AP
Hi,

I need to check if the event object I get has been generated by a JTextField or JTextArea.

How Can I check this?

Thanks.
 
You don't specify which event object you mean. However, all events which derive from java.awt.event.ComponentEvent have a getComponent() method which returns the java.awt.Component instance of the originating component.

This could have been easily discovered by using the Java API Docs which are freely available from Sun. If you are writing anything more than a trivial application in Java I recommend you obtain this and become familiar with its use.

Tim
 
It it's an EventObject, you have a getSource method.

Cheers,
Dian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top