ok in pratica mi stai dicendo di creare un classe che rappresenta uno StyledDocument e poi settare questo document come predefinito nel JTextPane, giusto?
se è così ho iniziato a creare una classe ma ho qualche dubbio:
codice:
public class myStyleDocument extends DefaultStyledDocument {
public void createStyle() throws BadLocationException {
StyledDocument document = new DefaultStyledDocument();
SimpleAttributeSet attributes = new SimpleAttributeSet();
attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
attributes.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.BLUE);
document.insertString(document.getLength(), null, attributes); // METTERE LE DIRECTORY
attributes = new SimpleAttributeSet();
attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
attributes.addAttribute(StyleConstants.CharacterConstants.Foreground, Color.BLACK);
document.insertString(document.getLength(), null, attributes); // METTERE I FILES
}
}
quello che nn mi viene è come aggiungere il testo che rappresenta file e directory.
cioè, posso usare qua StringBuilder e aggiungere il testo richiamando i metodi che ho scritto a inizio discussione?
o devo modificarli per usare solo String?
o ho sbagliato tutto??