Java examples for javax.swing.text:AttributeSet
get value from Swing text Attribute
//package com.java2s; import java.util.Enumeration; import javax.swing.text.AttributeSet; public class Main { public static String get(AttributeSet a, String attributeName) { for (Enumeration en = a.getAttributeNames(); en.hasMoreElements();) { Object name = en.nextElement(); if (name.toString().equalsIgnoreCase(attributeName)) { return a.getAttribute(name).toString(); }//from w w w.ja v a2 s. c o m } return null; } public static String toString(AttributeSet a) { StringBuilder builder = new StringBuilder("["); Enumeration en = a.getAttributeNames(); do { if (!en.hasMoreElements()) { break; } Object name = en.nextElement(); builder.append(name).append("=").append(a.getAttribute(name)); if (en.hasMoreElements()) { builder.append(", "); } } while (true); builder.append("]"); return builder.toString(); } }