Default Font in JEditPane

Hi all,

I'm going crazy trying to figure out how to set the default Font that a JEditPane should use. I'm using JEditPane as a TableCellEditor and TableCellRenderer, so even if I manage to set the Font used by the editor when inserting new text, I can't find a way to make the JEditPane use a specific Font when setting the text on an empty pane...

I'm using the StyledEditorKit (I need to be able to count the number of lines in the pane... even when they are wrapped).

I appreciate any help here...

LVL 3
schybertAsked:
Who is Participating?
 
mmuruganandamConnect With a Mentor Commented:
Check the demo in your jdk installer path.  There you have "Stylepad" folder.  Within that you can see how to add the font family action in the StylePad.java

0
 
mmuruganandamCommented:
did you try setFont method of JEditorPane

If you want to render something then you can also use the HTML tags for font.  <font face="Arial'>hai</font>

That way you will get that font.
0
 
schybertAuthor Commented:
Well, I have tried setFont actually :-) And as I said, I need to use the StyledEditorKit... not HTML.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
mmuruganandamCommented:
okie

StyledEditorKit.FontFamilyAction try this..
0
 
schybertAuthor Commented:
Yeah, but how do I use it? I need to execute the action explicity from within a method. An example would be very appreciated...
0
 
schybertAuthor Commented:
OK, thanks. I don't have time to test this until tomorrow, so if if it solves my problem I'll accept your answer then.
0
 
schybertAuthor Commented:
Well, I can do a workaround with this solution, but it's not really what I was aiming for... I have to execute the action each time I insert new text into the pane... What I was hoping to do was set the Font that will be used by the pane as default...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.