Source Code : Sharing Styles Between JTextPanes
Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com.
Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com.
Click Here or search from google with Libraries Name you get jar file related it
Sharing Styles Between JTextPanes
import java.awt.Color;
import javax.swing.JTextPane;
import javax.swing.text.DefaultStyledDocument;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyleContext;
public class Main {
public static void main(String[] argv) throws Exception {
JTextPane c1 = new JTextPane();
JTextPane c2 = new JTextPane();
StyleContext styleContext = new StyleContext();
c1.setDocument(new DefaultStyledDocument(styleContext));
c2.setDocument(new DefaultStyledDocument(styleContext));
Style style = c1.addStyle("style name", null);
StyleConstants.setForeground(style, Color.red);
style = c2.getStyle("style name");
StyleConstants.setBold(style, true);
}
}
Thank with us