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

📄 e1008. sharing styles between jtextpanes.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
Styles are stored in a style context. By default, text panes do not share style contexts, so any styles created for a text pane are available only in that text pane. This example creates two text panes that share a style context. Any new styles created in one text pane are available in the other. This also applies to changes in a shared style. 
    JTextPane c1 = new JTextPane();
    JTextPane c2 = new JTextPane();
    
    // Create new styled documents with the same style context
    StyleContext styleContext = new StyleContext();
    c1.setDocument(new DefaultStyledDocument(styleContext));
    c2.setDocument(new DefaultStyledDocument(styleContext));
    
    // Create a new style with one text pane
    Style style = c1.addStyle("style name", null);
    StyleConstants.setForeground(style, Color.red);
    
    // Modify an existing style using the other text pane
    style = c2.getStyle("style name");
    StyleConstants.setBold(style, true);

⌨️ 快捷键说明

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