• 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

TextArea

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

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.
Is it B) an D)
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And C: It says MAXIMUM. SO it may display less due to font, but it won't display MORE, right?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, none of the statements are true since you can't assign a TextArea to a TextField reference. Aside from that though, if we declare t as a TextArea too, then it's possible to have more than 5 characters on a line, or less. "Proportional pitch" means that some characters are thin and some are wide, and TextArea tries to be wide enough for 5 "average" characters. But in the demo I just tried, I could fit ten "l"'s into a line, or almost three "W"'s. And that's just how many characters are displayed at one time. There is no set maximum to the number of characters you can put on a line, thanks to the scrollbar.
 
Tony Alicea
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Was that in a Mac? In Windows? In some UNIX?
So what do you think is the right answer for the exam? I think that's a good question because I wonder if the exam wants answers from the Sun docs, or answers that depend on one executing every conceivable combination of GUI components in every platform?
What do you think?
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was using Windows 98. The API doesn't actually address the issue as far as I can see, so I'd have to say that no guarantees can be made about any platform's implementation. So the statement "The maximum number of characters in a line will be five" would have to be false in general, as there is no particular guaranteed maximum if the font is proportional-pitch.
Note that our beloved R&H does say (p. 329): "For a proportional font, the column width is taken to be the average of all the font's character widths." Which seems to be accurate on the one platform I tried.
 
Tony Alicea
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Note that our beloved R&H does say (p. 329): "For a proportional font, the column width is taken to be the average of all the font's character widths." Which seems to be accurate on the one platform I tried."
By now I have noticed that the point above about proportional fonts in (at least) TextArea and TextField is mentioned in many mock exams so I would say that that is an important thing to remember when taking the exam.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic