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

need help with StlyedDocument

 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am writing a simple word processor using the "using text components" tutorial as a starting point.
some of it was straightforward copy and paste: bold, italic, underline. others i figured out by extrapolation: left center right. i am having problems though with font type, font size, and color.
these i am changing from the tutorial. i use JComboBox for type and size, and JColorChooser for color.

i need help! it is all too confusing.
i think i need to use this method from StyledDocument
doc.setLogicalStyle(pane.getCaretPosition(), style);
but Style is an Interface as are the rest of this motly crew.
their code:

my code:





also, why did they do this?

if i need to use setLogicalStyle() i can't do it using and AbstractDocument

please supply some code or link to useful information.
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found something that might be usefull here

your help still appreciated
 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i found some more help:


however, i need to set the font not the font family
it is obviously possible to set the font since i could do it for the entire JTextPane.

however for the document all i can find is FontFamily
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
not sure if isn't threre an issue with LabelView & FONT.getStyle

 
Randall Twede
Ranch Hand
Posts: 4363
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i figured it out for the most part. i was misled sort of by the tutorial. i was under the impression that FontFamily could be only "serif" or "sans serif" and the font name was something different. as it turns out the font names(Arial, Times New Roman, etc) are font families. i still have a couple of problems, but i will start a different thread for them. i would do it now, but i don't have my laptop with me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic