• 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

Alignment of text in JTextPane

 
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I have a small problem. The user can type in text in a JTextPane. They can choose bild, italic and so on.

I must support Alignment. Certain block must be able to align center, right, left.

I don't quite know how to do this. My plan was to use a <p>Data goes here</p> tag after the user hit a carriage return. Is this the best approach?

how do I insert a <p></p>? Must i use CaretListener or is there another way?

Thanks Mathias
 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I resolved it myself ..... but I face another problem here.

If I use StyleConstants then is can mark a text as <u>text here</u> .... but what if I would like to add a <H1>Text here</H1> in my <p> tag

Example

<p align=left>hi there! <H1>text</H1>. ipsum lorum</p>

Any suggestions?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic