 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
haddock Guest
|
Posted: Tue Mar 22, 2005 3:07 pm Post subject: testing for object ancestry |
|
|
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
|
Posted: Tue Mar 22, 2005 3:22 pm Post subject: Re: testing for object ancestry |
|
|
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
|
Posted: Thu Mar 24, 2005 6:08 pm Post subject: Re: testing for object ancestry |
|
|
thanks so much Ulf, I knew it was a very basic thing...
|
|
| Back to top |
|
 |
|
|
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
|
|