aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "AWT" Watch "AWT" New topic
Author

AWT

Shafeeq Sheikh
Ranch Hand

Joined: May 12, 2000
Posts: 68
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...
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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).
Shafeeq Sheikh
Ranch Hand

Joined: May 12, 2000
Posts: 68
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
rajsim
Ranch Hand

Joined: May 31, 2000
Posts: 116
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.
 
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: AWT
 
Similar Threads
TextArea
///incompatible types///
text area
TextArea
Strange show