AttributeSet Example

Given an AttributeSet this method prints the attributes in name=value format:

  private void listAttributes(AttributeSet attributes) {
    Enumeration e = attributes.getAttributeNames();
    while (e.hasMoreElements()) {
      Object name = e.nextElement();
      Object value = attributes.getAttribute(name);
      System.out.println(name + "=" + value);
    }
  }

Although the argument and return types of these methods are mostly declared in terms of java.lang.Object, in practice all values are instances of java.lang.String while all names are instances of the public inner class javax.swing.text.html.HTML.Attribute.


Previous | Next | Top | Cafe con Leche

Copyright 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified January 28, 2000