• 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

Fixed width Proportional width font?

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
Thanks.
 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
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?
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Parag
Check this posting.
[urlhttp://www.javaranch.com/ubb/Forum24/HTML/005310.html[/url]
 
reply
    Bookmark Topic Watch Topic
  • New Topic