jeudi 26 novembre 2015

Syntax highlighting using JTextPane and DefaultStyledDocument

As in the topic, I want to create text pane containing highlighted code. But I have no idea how to create abstract class, which will be used to support multiple programming languages (like Notepad++). Or should I use interface?

public abstract MyAbstractDocument extends DefaultStyledDocument
{
    private AttributeSet[] attributes;
    private String[] keywords;
    /* getters and abstract setters */ 
}

I'm not sure if the interface will be easier here...

    public interface MyDocumentInterface
    {
        /* getters and setters */
        public abstract void recolor(StyledDocument doc); // support
        // for coloring syntax
    }

I want to use abstract factory to detect (by file extension) which document should be loaded. And one more question - how to color only last changes? Should I use buffer storing recent changes?

Aucun commentaire:

Enregistrer un commentaire