File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes TextFields and TextArea, cols parameter, Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "TextFields and TextArea, cols parameter," Watch "TextFields and TextArea, cols parameter," New topic
Author

TextFields and TextArea, cols parameter,

PGautam
Greenhorn

Joined: Mar 02, 2000
Posts: 19
If we construct a textfield tf, using costructor (int nCols = 5), after tf is created, i'm able to enter more characters than specified ncols in constructor. I thought it won't allow me to enter more than specified columns. Can somebody please clarify me. This is same behavior for textArea's.
Thanks
Honey
Greenhorn

Joined: Mar 02, 2000
Posts: 7
You need to know the difference between propotional pitch font and fixed pitch font.
Read this topic first.


greenhorn
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
Actually, I think PGautam is talking about something slightly different - not how many characters are displayed in one line, but how many characters you can type in one line, with scrolling. The latter has nothing to do with font type. The simple answer is, TextField and TextArea do not allow you to limit the number of characters on a line - only the number displayed at one time. (And only approximately, especially for proportional pitch fonts.)


"I'm not back." - Bill Harding, Twister
PGautam
Greenhorn

Joined: Mar 02, 2000
Posts: 19
Thanks Jim.
Honey
Greenhorn

Joined: Mar 02, 2000
Posts: 7
If you are talking about TextField , there is no question of scrolling.(beware ???)
I think ,atleast you should read this.You will get the answer:
The width of a "column" is equal to the width of a character, in the particular font being used. In the case of fixed pitch fonts, where all the characters are the same size, this is straightforward. For proportional fonts, the width of a column is equal to the average of the width of all the characters in the font. This means, for example, if you had text component with a proportional font and a width of 10 columns, if you use a narrow letter such as 'i', more than 10 'i's could be displayed.
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
A TextField does not allow any vertical scrolling, however it does allow horizontal scrolling. So if you keep on typing past the "limit", it just scrolls horizontally to display as much as you want to type. There's no scrollbar, but you can use the arrow keys to move back and forth.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: TextFields and TextArea, cols parameter,
 
Similar Threads
GridLayout Manager Doubt
Help needed with GridLayout example
About GridBagLayout
Restricting the TextField To accept only a set no of characters
file formatter for excel