Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting character width gap between characters in jtextpane

 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all, just wondering if it is possible to set a space character's width when painted in a jtextpane?

this is because i want to draw a fat symbol on the space character
 
Darryl Burke
Bartender
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the JTextPane (not jtextpane) has a HTMLDocument, you can use & n b s p ; (without the spaces) along with one (or flanked by two) normal space characters.

edit The nbsp is parsed even within code tags?
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no. i dont want that. i actually am going to draw/paint a symbol to replace the space

im guessing you have to customize the View but if there is a way to set a space character's width without creating a custom View, that is what i am looking for
 
Campbell Ritchie
Sheriff
Posts: 48404
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote: . . . The nbsp is parsed even within code tags?
I tried it and I had it parsed inside code tags too.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is what im following

http://java-sl.com/showpar.html

however, the middle dot is so small. i want to replace it with a bigger symbol
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 

Simply escape the & with & when posting:  
 
Stanislav Lapitsky
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible by custom GlyphPainter. See for example http://java-sl.com/gp_effects.html
You can use the same approach to enlarge space only.
 
mark goking
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks. will check this
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic