This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Fixed width Proportional width  font? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Fixed width Proportional width  font?" Watch "Fixed width Proportional width  font?" New topic

Fixed width Proportional width font?

parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
Can someone tell me what is the actual difference between Fixed width and Proportional width font?
And also how this affect text field.
TextField(int n) is the constructor n is the number of visible columns. Suppose n is 15. If i am displaying i then I can see more than 15 i, but if i want to see w i can see less then 15 colums.
Why does this occur.
Please throw some light on this point.
sean cee
Ranch Hand

Joined: Oct 24, 2000
Posts: 115
Hi Parag,
It happens when the Font is Proportional Width Font.
when You create TextField of width 15, the actual width is calculated by multiplying 15 by avg width of all letters in the Font. so if you type 15 W's which is widest letter, than you won't see all.
but the Font is Fixed width, it is different, every letter has fixed width, and when the text field was created it will use that fixed width * 15. so when you type a letter , you will see everything as long as they are 15 letter long.
Correct me if I am wrong, Gurus..

Sean <br />SCJP2, SCJP2p1.4, SCWCD
sarim raza
Ranch Hand

Joined: Nov 02, 2000
Posts: 232
Hi Parag:
Whenever you create a textfield object specifying the number of visible columns, to be 15 in this case, THE ONLY TIME WHEN YOU WILL ACTUALLY SEE 15 CHARACTERS will be when the textfield has its preferred size AND the font is of a fixed width.
preferred size: means that it has its actual size as allowed by the Flow layout
fixed width font: means that the size of all columns will be the same and will compress a 'w' char to be in the same size column like an 'i' char.
proportinonal width font: a 'w' char will occupy more space than an 'i' and the column size will be the average width of all the characters.
you seem to be using a proportional width font, which will cause the 'w' to go beyond the display area, but will cause you to see more than 15 'i' s
try a fixed font like monospaced.

parag bharambe
Ranch Hand

Joined: Sep 01, 2000
Posts: 41
It really nice sean and sarim
I got most of what you are saying. But how can i decide wheather i am using Fixed/Proportionate Font?
Can you explain it?
greg clarke

Joined: Oct 06, 2000
Posts: 25
Check this posting.
I agree. Here's the link:
subject: Fixed width Proportional width font?
It's not a secret anymore!