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

📄 e989. inserting styled text in a jtextpane component.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
See the StyleConstants class for more attributes. 
    try {
        // Get the text pane's document
        JTextPane textPane = new JTextPane();
        StyledDocument doc = (StyledDocument)textPane.getDocument();
    
        // Create a style object and then set the style attributes
        Style style = doc.addStyle("StyleName", null);
    
        // Italic
        StyleConstants.setItalic(style, true);
    
        // Bold
        StyleConstants.setBold(style, true);
    
        // Font family
        StyleConstants.setFontFamily(style, "SansSerif");
    
        // Font size
        StyleConstants.setFontSize(style, 30);
    
        // Background color
        StyleConstants.setBackground(style, Color.blue);
    
        // Foreground color
        StyleConstants.setForeground(style, Color.white);
    
        // Append to document
        doc.insertString(doc.getLength(), "Some Text", style);
    } catch (BadLocationException e) {
    }

⌨️ 快捷键说明

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