• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to set default font for JTextPane

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
bit of a discussion here

https://coderanch.com/t/341693/GUI/java/font-family-empty-DefaultStyledDocument
 
I'm just a poor boy, I need no sympathy, because I'm easy come, easy go, little high, little low, little ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic