• 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
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

AWT

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Shafeeq Sheikh
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. TextField t = new TextArea("12345", 5, 5);
is wrong. do you mean
TextArea t = new TextArea("12345", 5, 5);
2.

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.

Hence B should be correct.
 
reply
    Bookmark Topic Watch Topic
  • New Topic