< prev index next >

src/java.desktop/share/classes/javax/swing/text/html/ObjectView.java

Print this page




  75      * Creates a new ObjectView object.
  76      *
  77      * @param elem the element to decorate
  78      */
  79     public ObjectView(Element elem) {
  80         super(elem);
  81     }
  82 
  83     /**
  84      * Create the component.  The classid is used
  85      * as a specification of the classname, which
  86      * we try to load.
  87      */
  88     protected Component createComponent() {
  89         AttributeSet attr = getElement().getAttributes();
  90         String classname = (String) attr.getAttribute(HTML.Attribute.CLASSID);
  91         try {
  92             ReflectUtil.checkPackageAccess(classname);
  93             Class<?> c = Class.forName(classname, true,Thread.currentThread().
  94                                        getContextClassLoader());

  95             Object o = c.newInstance();
  96             if (o instanceof Component) {
  97                 Component comp = (Component) o;
  98                 setParameters(comp, attr);
  99                 return comp;
 100             }
 101         } catch (Throwable e) {
 102             // couldn't create a component... fall through to the
 103             // couldn't load representation.
 104         }
 105 
 106         return getUnloadableRepresentation();
 107     }
 108 
 109     /**
 110      * Fetch a component that can be used to represent the
 111      * object if it can't be created.
 112      */
 113     Component getUnloadableRepresentation() {
 114         // PENDING(prinz) get some artwork and return something




  75      * Creates a new ObjectView object.
  76      *
  77      * @param elem the element to decorate
  78      */
  79     public ObjectView(Element elem) {
  80         super(elem);
  81     }
  82 
  83     /**
  84      * Create the component.  The classid is used
  85      * as a specification of the classname, which
  86      * we try to load.
  87      */
  88     protected Component createComponent() {
  89         AttributeSet attr = getElement().getAttributes();
  90         String classname = (String) attr.getAttribute(HTML.Attribute.CLASSID);
  91         try {
  92             ReflectUtil.checkPackageAccess(classname);
  93             Class<?> c = Class.forName(classname, true,Thread.currentThread().
  94                                        getContextClassLoader());
  95             @SuppressWarnings("deprecation")
  96             Object o = c.newInstance();
  97             if (o instanceof Component) {
  98                 Component comp = (Component) o;
  99                 setParameters(comp, attr);
 100                 return comp;
 101             }
 102         } catch (Throwable e) {
 103             // couldn't create a component... fall through to the
 104             // couldn't load representation.
 105         }
 106 
 107         return getUnloadableRepresentation();
 108     }
 109 
 110     /**
 111      * Fetch a component that can be used to represent the
 112      * object if it can't be created.
 113      */
 114     Component getUnloadableRepresentation() {
 115         // PENDING(prinz) get some artwork and return something


< prev index next >