Hi Guys .... here's a question from a mock exam.... Given a TextArea using a proportional pitch font and constructed like this: TextField t = new TextArea("12345", 5, 5); Which statement is true? A.The displayed width shows exactly five characters on each line unless otherwise constrained B.The displayed height is five lines unless otherwise constrained. C.The maximum number of characters in a line will be five. D.The user will be able to edit the character string. E.The displayed string can use multiple fonts. The answer given is A and D. I didn't quite get it..... can somebody explain please....??? Thanks...
The constructed text area has 5 rows and 5 columns and NOT necessarily 5 visible rows and 5 visible columns. When you use a proportional pitch font, the width of each character may not be the same. For example, width of character W is more than the width of character I. You may be able to put five 'I' one next to each other and also see all of them. Similarly you may not be able to see five 'W' characters one next to each other. When a proportional pitch font is used, the width of each character computed will be equivalent to the average width of all the characters in the set the font supports. Hence you can never guarantee an area of width 5 characters will indeed show 5 visible characters. What you can guarantee is that each line will accomadate upto 5 characters only, and the sixth one might spill over to the next line. Hope this helps. Ajith
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Joined: May 12, 2000
Hi Ajith..... Got your point..... but as you said the field will have 5 columns and 5 rows. In that case why isin't 'B' also true??? Thanks, Shafeeq
Originally posted by Ajith Kallambella: What you can guarantee is that each line will accomadate upto 5 characters only, and the sixth one might spill over to the next line.
You can type in more than 5 characters per line in the text box created. Until you press "Enter" the characters will go on the same line. You can also have more than 5 text lines. (I just tried). The parameter is used to define approximate no of visible columns. However, the number of rows displayed seems to be exact.