File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Getting component type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Getting component type" Watch "Getting component type" New topic
Author

Getting component type

Barry Brashear
Ranch Hand

Joined: Jun 05, 2001
Posts: 303
If an object of type componet is coming into a method, what is the best
way to detemine it's type, such as checking if it's a JInternalFrame, or
JPanel?

Thanks.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
You mean, if you have an reference, of compile-time type Component, how do you find out the run-time type of the object to which it points?

Usually, you would use the "instanceof" operator.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Lionel Badiou
Ranch Hand

Joined: Jan 06, 2005
Posts: 140
Hello Barry,

You may try .

Hope that helps,


Lionel Badiou
CodeFutures Software
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You can also use reflection:

Of course, this may be of only limited use depending what you need to do with this information once you have it.

Layne


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting component type
 
Similar Threads
problem with j2sdkee1.3.1
Indenting code in posted text
please help me out.. exam tomorrow
synchronize block
Problem JSF as RuntimeException: Cannot find FacesContext