⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e1010. listing the attributes in a style.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
The way to retrieve the attributes in a style is to enumerate all the attribute names in the style and then use the specific attribute name to retrieve its value. The attribute name can be either a string or an object of type StyleConstants. 
    // To retrieve a style from a text pane, see
    // e1009 Listing the Styles Associated with a JTextPane
    
    // Get number of attributes
    int count = style.getAttributeCount();
    
    // Get enumeration of attribute names; an attribute name can be
    // either a string or a StyleConstants object
    Enumeration enum = style.getAttributeNames();
    while (enum.hasMoreElements()) {
        Object o = enum.nextElement();
        if (o instanceof String) {
            String attrName = (String)o;
            Object attrValue = style.getAttribute(attrName);
        } else if (o == StyleConstants.NameAttribute) {
            // Retrieve the style's name
            String styleName = (String)style.getAttribute(o);
        } else if (o == StyleConstants.ResolveAttribute) {
            // Retrieve the style's parent
            Style parent = (Style)style.getAttribute(o);
        } else {
            // Retrieve the style constant name and value
            String attrName = o.toString();
            Object attrValue = style.getAttribute(o);
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -