Package javax.swing.text

Examples of javax.swing.text.EditorKit


        if (!contentTypes.containsKey(type)) {
            type = PLAIN_CONTENT_TYPE;
        }

        if (changeEditorKit(type)) {
            EditorKit kit = getEditorKitForContentType(type);
            updateEditorKit((kit != null) ? kit : new PlainEditorKit());
            updateDocument(editorKit);
        }
    }
View Full Code Here


    private void updateEditorKit(final EditorKit kit) {
        if (editorKit != null) {
            editorKit.deinstall(this);
        }
        EditorKit oldEditorKit = editorKit;
        if (kit != null) {
            kit.install(this);
        }
        editorKit = kit;
        firePropertyChange("editorKit", oldEditorKit, kit);
View Full Code Here

    private HTML() {
    }

    public static void convertHtmlToText(Reader reader, Writer writer) throws IOException, BadLocationException {

        EditorKit kit = new HTMLEditorKit();
        HTMLDocument doc = new HTMLDocument();
        kit.read(reader, doc, 0);

        HTMLtoPlainTextWriter2 x = new HTMLtoPlainTextWriter2(writer, doc);
        x.write();
        writer.close();
View Full Code Here

        }
    }//GEN-LAST:event_jButton2ActionPerformed


    private void updateTheme(ColorTheme theme, JEditorPane pane) {
        EditorKit editorKit = pane.getEditorKit();
       
        Color background = new Color(0xffffff);
        Color currentLine = new Color(0xefefef);
        Color selection = new Color(0xd6d6d6);
        Color foreground = new Color(0x4d4d4c);
        Color comment = new Color(0x8e908c);
       
        Color blue = new Color(0x4271ae);
        Color green = new Color(0x718c00);
        Color purple = new Color(0x8959a8);
        Color red = new Color(0xc82829);
        Color orange = new Color(0xf5871f);
        Color yellow = new Color(0xeab700);


       
        DefaultSyntaxKit kit = (DefaultSyntaxKit) editorKit;
        pane.setBackground(background);
        //0 = default style
        //2 = italic
        //1 = bold
        kit.setProperty("Style.COMMENT", toHex(comment,2))//block and line comments
        kit.setProperty("Style.COMMENT2", toHex(Color.PINK,0)); //??
        kit.setProperty("Style.DEFAULT", toHex(foreground,0));
        kit.setProperty("Style.DELIMITER", toHex(Color.PINK,1));
        kit.setProperty("Style.ERROR", toHex(Color.PINK,3));
        kit.setProperty("Style.IDENTIFIER", toHex(blue,0)); //everything?
        kit.setProperty("Style.KEYWORD", toHex(purple,1)); //
        kit.setProperty("Style.KEYWORD2", toHex(purple,1)); // #include
        kit.setProperty("Style.NUMBER", toHex(red,1)); //number literals
        kit.setProperty("Style.OPERATOR", toHex(foreground,0)); //plus, dot, comma, asterix, etc
        kit.setProperty("Style.REGEX", toHex(foreground,0));
        kit.setProperty("Style.STRING", toHex(green,0)); //string literals
        kit.setProperty("Style.STRING2", toHex(Color.PINK,0));
        kit.setProperty("Style.TYPE", toHex(green,0)); //void, int
        kit.setProperty("Style.TYPE2", toHex(Color.PINK,0));
        kit.setProperty("Style.TYPE3", toHex(Color.PINK,0));
        kit.setProperty("Style.WARNING", toHex(Color.PINK,0));
       
        kit.setProperty("CaretColor", toHex(red));
        kit.setProperty("SelectionColor", toHex(selection));
        kit.setProperty("PairMarker.Color",toHex(yellow));
        kit.setProperty("TokenMarker.Color",toHex(yellow));
        kit.setProperty("LineNumbers.Background",toHex(currentLine));
        kit.setProperty("LineNumbers.CurrentBack",toHex(selection));
        kit.setProperty("LineNumbers.Foreground",toHex(Color.BLACK));
        kit.setProperty("LineNumbers.RightMargin","7");
       
        /*
        Style.COMMENT 0x339933, 2
Style.COMMENT2 0x339933, 3
Style.DEFAULT 0x000000, 0
Style.DELIMITER 0x000000, 1
Style.ERROR 0xCC0000, 3
Style.IDENTIFIER 0x000000, 0
Style.KEYWORD 0x3333ee, 0
Style.KEYWORD2 0x3333ee, 3
Style.NUMBER 0x999933, 1
Style.OPERATOR 0x000000, 0
Style.REGEX 0xcc6600, 0
Style.STRING 0xcc6600, 0
Style.STRING2 0xcc6600, 1
Style.TYPE 0x000000, 2
Style.TYPE2 0x000000, 1
Style.TYPE3 0x000000, 3
Style.WARNING 0xCC0000, 0
*/
        editorKit.install(pane);
        pane.setFont(customFont.deriveFont(14f));
    }
View Full Code Here


        // ----------------
        // 4) HTMLEditorKit

        EditorKit ekt = epn.getEditorKit();

        if (ekt == null)
        {
            String str = "ekt == null"; // !!!!!!!!!!
            //GfrHelpBroker._LOGGER_.info(str);
View Full Code Here

        if (index < 0) {
            return null;
        }
        String kitName = (String)editorKitNames.get(index);
        Object loader = classLoaders.get(index);
        EditorKit editorKit = null;

        try {
            editorKit = (EditorKit)((loader != null) ? ((ClassLoader)loader)
                    .loadClass(kitName).newInstance() : Class.forName(kitName)
                    .newInstance());
View Full Code Here

    public EditorKit getEditorKitForContentType(final String type) {
        int index = localContentTypes.indexOf(type);
        if (index >= 0) {
            return (EditorKit)localEditorKits.get(index);
        }
        EditorKit kit = JEditorPane.createEditorKitForContentType(type);
        return (kit == null) ? createDefaultEditorKit() : kit;
    }
View Full Code Here

    private void updateEditorKit(final EditorKit kit) {
        if (editorKit != null) {
            editorKit.deinstall(this);
        }
        EditorKit oldEditorKit = editorKit;
        if (kit != null) {
            kit.install(this);
        }
        editorKit = kit;
        firePropertyChange("editorKit", oldEditorKit, kit);
View Full Code Here

            }
            throw new IllegalArgumentException("Document must be HTMLDocument");
        }

        protected HTMLEditorKit getHTMLEditorKit(final JEditorPane pane) {
            EditorKit editorKit = pane.getEditorKit();
            if (editorKit instanceof HTMLEditorKit) {
                return (HTMLEditorKit)editorKit;
            }
            throw new IllegalArgumentException("Editor kit must be HTMLEditorKit");
        }
View Full Code Here

     *
     * @return the value obtained from the first UI, which is
     * the UI obtained from the default <code>LookAndFeel</code>
     */
    public EditorKit getEditorKit(JTextComponent a) {
        EditorKit returnValue =
            ((TextUI) (uis.elementAt(0))).getEditorKit(a);
        for (int i = 1; i < uis.size(); i++) {
            ((TextUI) (uis.elementAt(i))).getEditorKit(a);
        }
        return returnValue;
View Full Code Here

TOP

Related Classes of javax.swing.text.EditorKit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.