• 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

jtextarea change font size

 
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic