• 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

Locking the JText Area

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


How can I lock the j text area so that the user cannot edit the text?
Also how can I make "Archers" in bold?


Thank you very much for your help!
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> How can I lock the j text area so that the user cannot edit the text?
ta.setEditable(false);
(where ta = your textArea)

> Also how can I make "Archers" in bold?
ta.setFont(ta.getFont().deriveFont(Font.BOLD));
note: this will change the font for all the text in the textArea
 
Mabel Ahmad
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for your help.

I have another question. Would it be possible to set the size of a JTextArea? Like a set size of number of characters

For example if it was set to size 5 then it would looks like the the following examples [_____] <-- that is the JTextArea

[1____]
[23___]
[422__]
[42444]
[ February 18, 2006: Message edited by: Mabel Ahmad ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can:
set line wrap
change the font to monospaced
use FontMetrics to set the preferredSize

something like this



this will give you 3 rows.
I don't know whether you want a scrollpane, if so, it will cause problems
when the vertical scrollbar kicks in.
if you want to restrict it to e.g. 3 rows, you can add set the 'document' so
that it only accepts 15 characters (5 * 3 rows)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic