AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

testing for object ancestry

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help
View previous topic :: View next topic  
Author Message
haddock
Guest





PostPosted: Tue Mar 22, 2005 3:07 pm    Post subject: testing for object ancestry Reply with quote



hi all

this is bugging me for a while, it should be really simple, but
somehow I'm unable to look this one up myself... (I don't even know
where to look for it)

In my program I'd like to test, if the component that throws the
FocusGained Event is a member of the JTextComponent family, e.g. a
JTextField or a JTextArea, etc.

How can I write the line marked with *** do Java will understand what
I want?

thanks!
-------------------------------------------------------------------
public void focusGained(FocusEvent event)
{
Component comp = event.getComponent();
*** if (comp is a JTextComponent) doSomethingSpecial();

}
-------------------------------------------------------------------
Back to top
Ulf_N
Guest





PostPosted: Tue Mar 22, 2005 3:22 pm    Post subject: Re: testing for object ancestry Reply with quote



haddock skrev:
Quote:
hi all

this is bugging me for a while, it should be really simple, but
somehow I'm unable to look this one up myself... (I don't even know
where to look for it)

In my program I'd like to test, if the component that throws the
FocusGained Event is a member of the JTextComponent family, e.g. a
JTextField or a JTextArea, etc.

How can I write the line marked with *** do Java will understand what
I want?

thanks!
-------------------------------------------------------------------
public void focusGained(FocusEvent event)
{
Component comp = event.getComponent();
*** if (comp is a JTextComponent) doSomethingSpecial();

}
-------------------------------------------------------------------

Shouldn't this work:

if (comp instanceof JTextComponent) ...

/ulf

Back to top
haddock
Guest





PostPosted: Thu Mar 24, 2005 6:08 pm    Post subject: Re: testing for object ancestry Reply with quote



thanks so much Ulf, I knew it was a very basic thing...
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.