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


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Reflection" Watch "Java Reflection" New topic
Author

Java Reflection

simonph
Greenhorn

Joined: Jul 24, 2002
Posts: 2
Hi everyone,
I am facing a problem. I have an XML which contains tags
like JPanel,JTextField,JButton with attributes for creating UI screen. I am reading this XML file and creating objects using reflection and storing in an Object array. Now when I want to access the methods of JBtton,JTextField... I need to downcast it dynamically into its appropriate class. This is possible using instanceof operator. I need to avoid using if-else statements as I need to handle many swing components. Can I somehow dynamically downcast it, pls help.
Thnx in advance for the help
Regards
Simon
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Greetings Simon,
Welcome to JavaRanch, the absolute best site on the www for Java information. We don't have many rules around here, but we do have one. Please change your display name to a first and last name to conform with the JavaRanch Naming Policy. You can change it here:
Change your display name.
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Reflection