Package javax.swing.text

Examples of javax.swing.text.Style.addAttribute()


        StyledDocument newDoc = new DefaultStyledDocument();
        Style newStyle = newDoc.getStyle(StyleContext.DEFAULT_STYLE);
        assertNull(newStyle.getAttribute(StyleConstants.FontSize));
        assertNull(newStyle.getAttribute(StyleConstants.FontFamily));
        newStyle.addAttribute(StyleConstants.FontFamily, "family2");
        newStyle.addAttribute(StyleConstants.FontSize, new Integer(10));
        newStyle.addAttribute(StyleConstants.Italic, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
        newStyle.addAttribute(StyleConstants.Subscript, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.Foreground, Color.RED);
        textPane.setDocument(newDoc);
View Full Code Here


        Style newStyle = newDoc.getStyle(StyleContext.DEFAULT_STYLE);
        assertNull(newStyle.getAttribute(StyleConstants.FontSize));
        assertNull(newStyle.getAttribute(StyleConstants.FontFamily));
        newStyle.addAttribute(StyleConstants.FontFamily, "family2");
        newStyle.addAttribute(StyleConstants.FontSize, new Integer(10));
        newStyle.addAttribute(StyleConstants.Italic, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
        newStyle.addAttribute(StyleConstants.Subscript, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.Foreground, Color.RED);
        textPane.setDocument(newDoc);
        assertNotSame(style, newStyle);
View Full Code Here

        assertNull(newStyle.getAttribute(StyleConstants.FontSize));
        assertNull(newStyle.getAttribute(StyleConstants.FontFamily));
        newStyle.addAttribute(StyleConstants.FontFamily, "family2");
        newStyle.addAttribute(StyleConstants.FontSize, new Integer(10));
        newStyle.addAttribute(StyleConstants.Italic, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
        newStyle.addAttribute(StyleConstants.Subscript, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.Foreground, Color.RED);
        textPane.setDocument(newDoc);
        assertNotSame(style, newStyle);
        assertEquals(25, ((Integer) newStyle.getAttribute(StyleConstants.FontSize)).intValue());
View Full Code Here

        assertNull(newStyle.getAttribute(StyleConstants.FontFamily));
        newStyle.addAttribute(StyleConstants.FontFamily, "family2");
        newStyle.addAttribute(StyleConstants.FontSize, new Integer(10));
        newStyle.addAttribute(StyleConstants.Italic, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
        newStyle.addAttribute(StyleConstants.Subscript, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.Foreground, Color.RED);
        textPane.setDocument(newDoc);
        assertNotSame(style, newStyle);
        assertEquals(25, ((Integer) newStyle.getAttribute(StyleConstants.FontSize)).intValue());
        assertEquals(font.getName(), newStyle.getAttribute(StyleConstants.FontFamily));
View Full Code Here

        newStyle.addAttribute(StyleConstants.FontFamily, "family2");
        newStyle.addAttribute(StyleConstants.FontSize, new Integer(10));
        newStyle.addAttribute(StyleConstants.Italic, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.StrikeThrough, Boolean.TRUE);
        newStyle.addAttribute(StyleConstants.Subscript, Boolean.FALSE);
        newStyle.addAttribute(StyleConstants.Foreground, Color.RED);
        textPane.setDocument(newDoc);
        assertNotSame(style, newStyle);
        assertEquals(25, ((Integer) newStyle.getAttribute(StyleConstants.FontSize)).intValue());
        assertEquals(font.getName(), newStyle.getAttribute(StyleConstants.FontFamily));
        assertEquals(Boolean.TRUE, newStyle.getAttribute(StyleConstants.Italic));
View Full Code Here

        assertEquals(1, parent.getAttributeCount());
        assertNull(parent.getResolveParent());
        assertEquals(2, child.getAttributeCount());
        assertNotNull(child.getResolveParent());
        parent.addAttribute(StyleConstants.Bold, Boolean.FALSE);
        child.addAttribute(StyleConstants.Bold, Boolean.TRUE);
        assertFalse(((Boolean) parent.getAttribute(StyleConstants.Bold)).booleanValue());
        assertTrue(((Boolean) child.getAttribute(StyleConstants.Bold)).booleanValue());
        // Add styles with diff parameters
        Style parent1 = textPane.addStyle("p1", null);
        Style parent2 = textPane.addStyle("p2", null);
View Full Code Here

    public void testGetLogicalStyle() throws BadLocationException {
        textPane.getStyledDocument().insertString(11, "bold", attrs);
        Style style = textPane.addStyle("bold", textPane.getStyle(StyleContext.DEFAULT_STYLE));
        textPane.setCaretPosition(1);
        style.addAttribute(StyleConstants.Bold, Boolean.TRUE);
        textPane.setLogicalStyle(style);
        style = textPane.getLogicalStyle();
        textPane.setCaretPosition(3);
        assertSame(style, textPane.getLogicalStyle());
        assertTrue(((Boolean) style.getAttribute(StyleConstants.Bold)).booleanValue());
View Full Code Here

        StyleConstants.setBold(attrs, true);
        // Add style
        Style style = textPane.addStyle("bold", textPane.getStyle(StyleContext.DEFAULT_STYLE));
        // Set style
        textPane.setCaretPosition(1);
        style.addAttribute(StyleConstants.Bold, Boolean.TRUE);
        assertFalse(StyleConstants.isBold(textPane.getParagraphAttributes()));
        textPane.setLogicalStyle(style);
        style = textPane.getLogicalStyle();
        textPane.setCaretPosition(3);
        assertSame(style, textPane.getLogicalStyle());
View Full Code Here

        // Set another style
        textPane.getStyledDocument().setCharacterAttributes(1, 1, attrs, true);
        assertFalse(StyleConstants.isUnderline(textPane.getParagraphAttributes()));
        assertFalse(StyleConstants.isUnderline(getCharacterAttributes(1)));
        style = textPane.addStyle("underline", textPane.getStyle(StyleContext.DEFAULT_STYLE));
        style.addAttribute(StyleConstants.Underline, Boolean.TRUE);
        textPane.setLogicalStyle(style);
        assertNotNull(textPane.getLogicalStyle());
        assertEquals("underline", textPane.getLogicalStyle().getAttribute(
                StyleConstants.NameAttribute));
        assertTrue(StyleConstants.isUnderline(textPane.getParagraphAttributes()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.