alistair
alistair

Reputation: 1172

Syntax highlighter for JEditorPane, font change produces offset bug

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

Answers (1)

mKorbel
mKorbel

Reputation: 109823

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.

  • todays HTML in Java is reduced for support HTML<=3.2 (partially supporting css & styles)

EDIT

Upvotes: 2

Related Questions