Reputation: 1172
I'm using a JEditorPane within a JScrollPane. I'm initialising the code as follows:
jsArea = new JEditorPane();
JScrollPane scrPane = new JScrollPane(jsArea);
scrPane.setMinimumSize(new Dimension(500, 710));
scrPane.setPreferredSize(new Dimension(500, 710));
scrPane.setMaximumSize(new Dimension(1600, 1600));
scrPane.setBorder(BorderFactory.createLineBorder (Color.white, 3));
jsArea.setContentType("text/javascript");
jsArea.setFont(Font.getFont("Arial"));
content.add(scrPane, c);
The editor works as expected, except when i type something like the following:
ctx.arc(1,2,3,4,5,6)
What happens here is the cursor (believing it is at the end of the line) hovers over "5" and movement of the cursor isn't consistant with the text being displayed. It works fine on the default font, but I need to use Arial.
**Note I'm using a syntax highlighter, too, which could be the problem.
Any help would be much appreciated.
Upvotes: 1
Views: 743
Reputation: 109823
text/html
or text/plain
or text/rtf
, not setContentType("text/javascript");
(usage for JSON
or Servlet
)If there is a charset definition specified as a parameter of the content type specification, it will be used when loading input streams using the associated EditorKit. For example if the type is specified as
text/html;
charset=EUC-JP the content will be loaded using the EditorKit registered for text/html and the Reader provided to the EditorKit to load unicode into the document will use the EUC-JP charset for translating to unicode. If the type is not recognized, the content will be loaded using the EditorKit registered for plain text,text/plain
.
HTML in Java
is reduced for support HTML<=3.2
(partially supporting css & styles)EDIT
HightLighter
Upvotes: 2