• Post Reply Bookmark Topic Watch Topic
  • New Topic

Alignment of text in JTextPane

 
Mathias Nilsson
Ranch Hand
Posts: 367
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!