?
Solved

Default Font in JEditPane

Posted on 2004-03-30
7
Medium Priority
?
230 Views
Last Modified: 2013-12-03
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...

0
Comment
Question by:schybert
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10721341
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
 
LVL 3

Author Comment

by:schybert
ID: 10721420
Well, I have tried setFont actually :-) And as I said, I need to use the StyledEditorKit... not HTML.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10721440
okie

StyledEditorKit.FontFamilyAction try this..
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 3

Author Comment

by:schybert
ID: 10721576
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
 
LVL 9

Accepted Solution

by:
mmuruganandam earned 375 total points
ID: 10721651
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
 
LVL 3

Author Comment

by:schybert
ID: 10721758
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
 
LVL 3

Author Comment

by:schybert
ID: 10729997
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn different types of Android Layout and some basics of an Android App.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question