Installing two EditorKit into JEditor Pane

Posted on 2005-04-20
Last Modified: 2008-02-01
Is it possible to install more than one EditorKit into JEditorPane.

I want to install a EditorKit that displays line numbers and a EditorKit which highlights the Java key words.
If I try to install two Editor kit one of them would not work…

          JEditorPane editor = new JEditorPane();
            editor.setEditorKit(new NumberedEditorKit());
          JavaEditorKit kit = new JavaEditorKit();
          editor.setEditorKitForContentType("text/java", kit);
          editor.setFont(new Font("Courier", 0, 12));

Here are the web sites where I got all the codes…
Question by:csound
    1 Comment
    LVL 15

    Accepted Solution

    The EditorKit that will be used/active is based on the content value that the editor was set with.
    Having editor.setContentType("text/java"); will cause the JavaEditorKit to be active.
    I don't think you can make two EditorKit active at the same time.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    VB Script 3 60
    hash value 2 29
    Problem to setup 18 67
    ArrayLists in ArrayLists/HashMaps? 4 30
    For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now