public String getNameByReflection(Object obj)
    {
        Object name = null;
        try {
            java.lang.reflect.Method method = obj.getClass().getMethod("getName");
            
            if (method != null)
                name = method.invoke(obj);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (name == null)
            return null;
        else
            return name.toString();
    }
public String getNameByReflection ( Object obj ) { Object name = null ; try { java . lang . reflect . Method method = obj . getClass ( ) . getMethod ( "getName" ) ; if ( method != null ) name = method . invoke ( obj ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } if ( name == null ) return null ; else return name . toString ( ) ; }
Lame method, since awt, swing, and android components all have setText methods.
@param obj
@param text