Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

JTextaArea - Lock the size, can it be done?

 
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey everyone,

I have been looking at the API and google, but I cannot find the answer to my question.

with a JTextArea can it be locked so that it only contains 2 rows and no more?
if so how can I do this?

davy
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
in this you would need to control the size of the textArea
e.g. frame.setResizable(false);

compile/run, start typing and it will be limited to 2 lines.
if you then narrow the frame, the typed text will go to 3 or more lines

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

If I understand you correctly, then here is how I do it:

(Code below... didnt bother with the code script as this is a subsection)
#######################################################################
import java.awt.Dimension; //need this for dimension

Dimension d = new Dimension(10,24);

JTextArea t3WorkoutTextArea = new JTextArea(10,24);

t3WorkoutJP.add(t3WorkoutTextArea);//add the text area to your jpanel
t3WorkoutTextArea.setPreferredSize(d); //ThIS WHAT YOU WERE ASKING ABOUT. It
//locks your columns and rows.

#######################################################################
Hope that helps.
[ May 01, 2007: Message edited by: Ryan Giomi ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic