Link to home
Start Free TrialLog in
Avatar of schybert
schybert

asked on

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...

Avatar of mmuruganandam
mmuruganandam
Flag of United States of America image

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.
Avatar of schybert
schybert

ASKER

Well, I have tried setFont actually :-) And as I said, I need to use the StyledEditorKit... not HTML.
okie

StyledEditorKit.FontFamilyAction try this..
Yeah, but how do I use it? I need to execute the action explicity from within a method. An example would be very appreciated...
ASKER CERTIFIED SOLUTION
Avatar of mmuruganandam
mmuruganandam
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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...