Package javax.swing.text.StyleContext

Examples of javax.swing.text.StyleContext.NamedStyle


    @Override
    protected void setUp() throws Exception {
        super.setUp();
        ns = (NamedStyle) style;
        StyleContext defContext = StyleContext.getDefaultStyleContext();
        withName = defContext.new NamedStyle("styleName", null);
    }
View Full Code Here


    /*
     * NamedStyle(String, Style)
     */
    public void testNamedStyleStringStyle() {
        Style parent = StyleContext.getDefaultStyleContext().new NamedStyle();
        parent.addAttribute("key", "value");
        String name = "style_name";
        ns = StyleContext.getDefaultStyleContext().new NamedStyle(name, parent);
        assertEquals(parent, ns.getResolveParent());
        assertEquals(name, ns.getName());
    }
View Full Code Here

    /*
     * NamedStyle(String, Style)
     */
    public void testNamedStyleStringNullStyle() {
        Style parent = StyleContext.getDefaultStyleContext().new NamedStyle("parentName", null);
        parent.addAttribute("key", "value");
        ns = StyleContext.getDefaultStyleContext().new NamedStyle(null, parent);
        assertEquals(parent, ns.getResolveParent());
        assertSame(parent, ns.getResolveParent());
        // Using getName we should have null
        assertNull(ns.getName());
        // But using get attribute, we should get parent name 'cause this
View Full Code Here

    /*
     * NamedStyle(String, Style)
     */
    public void testNamedStyleStringStyleNull() {
        ns = StyleContext.getDefaultStyleContext().new NamedStyle("styleName", null);
        assertNull(ns.getResolveParent());
        assertEquals("styleName", ns.getName());
    }
View Full Code Here

    /*
     * NamedStyle(String, Style)
     */
    public void testNamedStyleStringNullStyleNull() {
        ns = StyleContext.getDefaultStyleContext().new NamedStyle(null, null);
        assertNull(ns.getResolveParent());
        assertNull(ns.getName());
    }
View Full Code Here

    /*
     * NamedStyle(Style)
     */
    public void testNamedStyleStyle() {
        Style parent = StyleContext.getDefaultStyleContext().new NamedStyle();
        parent.addAttribute("key", "value");
        ns = StyleContext.getDefaultStyleContext().new NamedStyle(parent);
        assertEquals(parent, ns.getResolveParent());
        assertEquals(1, ns.getAttributeCount());
        assertEquals("value", ns.getAttribute("key"));
    }
View Full Code Here

    /*
     * NamedStyle()
     */
    public void testNamedStyle() {
        ns = StyleContext.getDefaultStyleContext().new NamedStyle();
        assertEquals(0, ns.getAttributeCount());
        assertNull(ns.getAttribute(AttributeSet.NameAttribute));
        assertNull(ns.getAttribute(AttributeSet.ResolveAttribute));
    }
View Full Code Here

        assertNull(ns.getAttribute(AttributeSet.NameAttribute));
        assertNull(ns.getAttribute(AttributeSet.ResolveAttribute));
    }

    public void testSetNameNull() {
        ns = StyleContext.getDefaultStyleContext().new NamedStyle("styleName", null);
        ns.setName(null);
        assertEquals("styleName", ns.getName());
    }
View Full Code Here

        ns.setName(null);
        assertEquals("styleName", ns.getName());
    }

    public void testSetName() {
        ns = StyleContext.getDefaultStyleContext().new NamedStyle();
        ns.setName("styleName");
        assertEquals("styleName", ns.getName());
        assertEquals("styleName", ns.getAttribute(AttributeSet.NameAttribute));
    }
View Full Code Here

        assertTrue(withName.containsAttribute(AttributeSet.NameAttribute, "styleName"));
        assertTrue(withName.containsAttributes(as));
    }

    public void testNameNotString() {
        ns = StyleContext.getDefaultStyleContext().new NamedStyle();
        ns.addAttribute(AttributeSet.NameAttribute, new Integer(15));
        assertEquals(new Integer(15), ns.getAttribute(AttributeSet.NameAttribute));
        assertEquals((new Integer(15)).toString(), ns.getName());
    }
View Full Code Here

TOP

Related Classes of javax.swing.text.StyleContext.NamedStyle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.