REFLECTION API
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   francois_bana
Posted On:   Monday, August 27, 2001 02:45 AM

Hello,
I have a question about the Reflection api. I want to set all the textfield from my panel to "". I want to use for that the reflection api.
I take all the fields of my panel and check if that is a JTextField. But how can i access to the objects JTextField to call the function setText("") from JTextField?

Thanks
Francois

Re: REFLECTION API

Posted By:   Dermot_Hennessy  
Posted On:   Monday, August 27, 2001 03:59 AM

Call instanceof for each field and for each field (I presume you are representing them as java.lang.Objects) that is a JTextField, cast to a JTextField and call the method in the standard way. Pseudo code:

Object[] theFields = panel.getFields();
//getFields() is pseudocode

for (int i = 0; i{
if (theFields[i] instanceof JTextField)
((JTextField)theFields[i]).setText("");
}

Dermot
About | Sitemap | Contact