How to get JEditorPane's row height?

I use a JEditorPane to display C source code. I add a JList to show line number.Besides,when mouse double click the JList,a breakpoint is add.I want to get JEditorPane's row height,then jList.set.setFixedCellHeight(height);The problem is how to get JEditorPane's row height.
[290 byte] By [shineyilia] at [2007-11-27 6:54:04]
# 1

A JEditorPane is for displaying HTML.

You should be using a JTextArea if you are showing plain text or JTextPane if you are using text with attributes.

JTextArea has a get line height method.

JTextPane doesn't have a method but you can get the font of the JTextPane and then get the FontMetrics of the Font and then get the line height information from the metrics.

camickra at 2007-7-12 18:28:56 > top of Java-index,Desktop,Core GUI APIs...
# 2

I use JEditorPane because c source code is not plain text.I insert html in it ,for keyword highlight.

The question is that FontMetrics does not work.

my code is :

jEditorpane.getFontMetrics(jEditorpane.getFont());

but the actual font is : <font size="..">...</font>.

shineyilia at 2007-7-12 18:28:56 > top of Java-index,Desktop,Core GUI APIs...
# 3

> but the actual font is : <font size="..">...</font>.

Well you shouldn't be changing the font size of the text. Editors should just highlight keywords not change the size.

> I insert html in it ,for keyword highlight.

I would use a JTextPane then. Its easier to use attributes than to play with HTML. Simple example:

http://forum.java.sun.com/thread.jspa?forumID=57&threadID=342068

camickra at 2007-7-12 18:28:56 > top of Java-index,Desktop,Core GUI APIs...
# 4
JTextPane works .Thank you .
shineyilia at 2007-7-12 18:28:56 > top of Java-index,Desktop,Core GUI APIs...
# 5
>I use JEditorPane because c source code is not plain text.have you ever seen a .c or .cpp file? what kind of file do you think is it? does .c or .cpp stores all font information? how do you make this kind of statements in a public forum ?
Aniruddha-Herea at 2007-7-12 18:28:56 > top of Java-index,Desktop,Core GUI APIs...
# 6

> >I use JEditorPane because c source code is not plain

> text.

>

> have you ever seen a .c or .cpp file? what kind of

> file do you think is it? does .c or .cpp stores all

> font information? how do you make this kind of

> statements in a public forum ?

I know that .c is plain text,does not store font information.I wnat to highlight keyword.I add font information for it.

shineyilia at 2007-7-12 18:28:56 > top of Java-index,Desktop,Core GUI APIs...
# 7
thats right. and this is why you should never say that c source code is not plain text. that conveys a wrong information to new people.regardsAniruddha
Aniruddha-Herea at 2007-7-12 18:28:56 > top of Java-index,Desktop,Core GUI APIs...