Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / July 2005

Tip: Looking for answers? Try searching our database.

Fixed size font

Thread view: 
Mary Walker - 26 Jul 2005 23:08 GMT
Hi,

I would like to draw a string to a panel using the Graphics object (g) i.e
g.drawString("Test",150,150); but I would like to be able to wrap a long
string around the width of the panel (a bit like a word processor would).
For this, I need a fix sized font where all the characters are the same
width.  However, the font set seems limitted and I have had no joy getting
access to a fix sized font.

Any ideas?

Regards,

Mary,
Andrew Thompson - 26 Jul 2005 23:27 GMT
> ..However, the font set seems limitted and I have had no joy getting
> access to a fix sized font.
>
> Any ideas?

Did you try each of the 'names' listed in this constructor?
<http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Font.html#Font(java.lang.String
,%20int,%20int
)>

If that is not ..giving you joy, you might try
describing your code more precisely, vis.
<http://www.physci.org/codes/sscce.jsp>

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Presented in BC [Brain Control] Where Available

Andrew Thompson - 26 Jul 2005 23:31 GMT
>> ..However, the font set seems limitted and I have had no joy getting
>> access to a fix sized font.
[quoted text clipped - 3 lines]
> Did you try each of the 'names' listed in this constructor?
> <http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Font.html#Font(java.lang.String
,%20int,%20int
)>

Or to put that another way..
<http://www.javasaver.com/sb/01/index.jsp?saver=humanrights>
(requires 1.5 ..probably)

..read the page carefully.  ;-)

Signature

Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
Too Hot For Radio

Thomas Weidenfeller - 27 Jul 2005 09:05 GMT
> I would like to draw a string to a panel using the Graphics object (g) i.e
> g.drawString("Test",150,150); but I would like to be able to wrap a long
> string around the width of the panel (a bit like a word processor would).
> For this, I need a fix sized font where all the characters are the same
> width.  However, the font set seems limitted and I have had no joy getting
> access to a fix sized font.

new Font("Monospaced", PLAIN, 10)

Please see the API documentation for details.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Mary Walker - 28 Jul 2005 16:42 GMT
>> I would like to draw a string to a panel using the Graphics object (g)
>> i.e g.drawString("Test",150,150); but I would like to be able to wrap a
[quoted text clipped - 8 lines]
>
> /Thomas

Thanks.  That worked fine,

regards,

Mary


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.