Hi again,
you can use SimpleAttributeSet to specify the textattributes like font and colors. To append the document, you get first the document by the getStyledDocument()-method of the JTextPane and then append it by using the insertString-method of the document with postion, text and your attributeset.
Hope this will help you
greetings Marsian
P.S.: Don't know much about the heavy-weight non-swing-components, I normally use swing.
ok, here is one example - it sets some Attrbutes in an array of 17 SimpleAttributeSets - this array is declared outside this method as SimpleAttributeset [] attr = new SimpleAttributeSet[17];
public void initAttrSet(int fontsize) {
attr[0]=new SimpleAttributeSet();
StyleConstants.setFontFamily(attr[0],"Courier New");
StyleConstants.setFontSize(attr[0],fontsize);
StyleConstants.setForeground(attr[0],Color.lightGray);
StyleConstants.setBackground(attr[0],Color.black);
attr[1]=new SimpleAttributeSet(attr[0]);
StyleConstants.setForeground(attr[1],Color.red);
attr[2]=new SimpleAttributeSet(attr[0]);
StyleConstants.setForeground(attr[2],Color.green);
attr[3]=new SimpleAttributeSet(attr[0]);
StyleConstants.setForeground(attr[3],Color.yellow);
// and so on ....
}
Hope this will help now
greetings Marsian
P.S.: if you wonder, why the background is black - I use it in a mud-client for a science fiction mud, there black background is more atmospheric :)
Hi again,
it is a german mud called finalfrontier - but I am not a Q, I am player - I just wrote my own client with integrated programming language, JIT-Compiler, virtual machine and such things. In finalfrontier it is forbiddden to use scripts and automatic triggers, so I had to find an other way to use this things in a mud-conform manner. I can't use the features of zmud there, so I had to do it my own way.
greetings Marsian
P.S.: if you will visit this mud, you will find me in the genetic guild - I am DNA-master of the biogenetic institute in Rat~Leihfi on planet Ch~Rihan in the Taladon system - ofcourse, as Marsian