• Post Reply Bookmark Topic Watch Topic
  • New Topic

jtextarea change font size

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

I wonder if it's possible to change the font size in a jtextarea so in every new line the text will increase.

in other words, when I do this:

Font f = new Font("Times Roman", Font.BOLD, 10);
jta.setFont(f);
jta.append("ELVIS");

f = new Font("Times Roman", Font.BOLD, 20);
jta.setFont(f);
jta.append("PRESLEY");

the result is font size 20.

how can I ensure that the word ELVIS will be size 10 and PRESLEY will be size 20

Thanks
Peter
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using a JTextPane with a StyledDocument. The JTextPane api has a link to a tutorial page with example code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!