• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to color text in JTextPane ???  RSS feed

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a JTextPane and it contains mainly text.

the test is produced from a database so it may look like this:

Name: Jim
Age: 33

ect...

the name of the person changes of course and I would like to color it in BLUE.

Question: how can I color the 'dynamic' text???


here is my code:

pane.replaceSelection(this.getText());
.
.
.

public String getText()
{
String text="Name: " + db.getName() +"\n"+
"Age: " + db.getAge() +"\n"...

}



Thanks for any ideas

Ppr
}
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to Use Editor Panes and Text Panes is a starting place to learn how to create styles that you can apply to text that you insert into a JTexPane document.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!