Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Font Size verus TextField Bounds

Posted on 1998-06-15
4
Medium Priority
?
325 Views
Last Modified: 2013-12-03
I always seem to have to edit, compile, run, edit, compile, run, etc...
when trying to get the TextField box to not cut off the text in it.

Is there any determinant way to set the bounds (height) of a TextField so that
the text that gets displayed in it doesn't get cut off.

I also need it to be platform and resolution independent.

I have tried three platforms:  Windows95, Linux (X), Solaris (CDE).
Windows handles it the best; whereis Solaris the worst.

0
Comment
Question by:mag062397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:imladris
ID: 1223211
Is the problem determining what height to set the TextField to, or getting the TextField to conform to the height you know it needs to be?

0
 

Author Comment

by:mag062397
ID: 1223212
Setting the TextField height so that it is large enough
to display the font, yet not too large.

That is, does there exist a constant, ?, such that
textField.setBounds(x, y, w, fontSize+?) is large enough
to display the font correctly and that ? is the smallest
constant that exists.

The answer probably depends on the font and/or fontsize; because
I tried setting the height to 25, font family to "TimesRoman" and
it displayed correctly for sizes 1-8 and 10 but not 9.  Strange!?

0
 
LVL 16

Accepted Solution

by:
imladris earned 600 total points
ID: 1223213
If you get a FontMetric for the font (in the Graphics class public FontMetrics getFontMetrics(Font f)) you can get the font height from it (public int getHeight()). There are also calls for getting the maximum ascent and descent (space above and below "regular" characters needed for this font.
This should allow for much more accuracy than a number based on font size.

0
 

Author Comment

by:mag062397
ID: 1223214
Yes, I'll do that -- Thanks!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question