This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to set default font for JTextPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to set default font for JTextPane" Watch "How to set default font for JTextPane" New topic
Author

How to set default font for JTextPane

Naresh Devasani
Greenhorn

Joined: Oct 26, 2006
Posts: 9
I have lot of issues while i am trying to write a "style pad" by using Editable JTextPane.
> Content type i am using is: "text/html"
> So, Document: HTMLDocument and Editor: HTMLEditorKit

1. I wanted to set the default font family/name as "Arial".
2. Set the paragraph attributes to set the font to Arial. It works fine. But at a later stage when i copy and paste the text to the textcomponent, pasted text is comming in the default font(Not Arial).
3. With paste, one more problem: it is not pasting the text in the cursor position. It is pasting in the next line.
4. How to read the current caret position's attributes.

When i use setFont on TextComponent's instance, it is not applying, since i am setting the required attributes(Bold/Italic/Underline) through the AttributeSet, at later stage.

So, anything i am doing wrong here?
Even if you dont get the problem exactly, my main goal is te set the Font as "Arial" and it should retain always, throughout the program.

Please help me on this.


Thanks,<br />Naresh
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
bit of a discussion here

http://www.coderanch.com/t/341693/GUI/java/font-family-empty-DefaultStyledDocument
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set default font for JTextPane
 
Similar Threads
How to change cursor height based on Font size
Font sizes in a JTextPane
checkboxes persistence
JTextPane problem ' ==> [] ??????????????
font color in JTextArea