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 / September 2005

Tip: Looking for answers? Try searching our database.

a simple FONT question...

Thread view: 
Frances - 08 Sep 2005 00:05 GMT
this is syntax for constructor:

Font(String name, int style, int size)

so how do you do BOLD AND ITALIC?  obviously this gives me an error..

    label.setFont(new Font("Arial", Font.BOLD, Font.ITALIC, 22));

           (did not find a BOLD-ITALIC property..)

thank you..

Frances
Thomas Hawtin - 08 Sep 2005 00:11 GMT
> so how do you do BOLD AND ITALIC?  obviously this gives me an error..
>
>     label.setFont(new Font("Arial", Font.BOLD, Font.ITALIC, 22));

>     label.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 22));

| is doing a bitwise or.

Font objects are actually quite expensive to create and dispose of. How
much is highly platform dependent. So if you're doing this often, us the
same Font object.

Tom Hawtin
Signature

Unemployed English Java programmer
http://jroller.com/page/tackline/

Oliver Wong - 08 Sep 2005 17:10 GMT
>> so how do you do BOLD AND ITALIC?  obviously this gives me an error..
>>
[quoted text clipped - 3 lines]
>
> | is doing a bitwise or.

   To get a better understanding of this, study some binary arithmatic and
boolean operators. ORing flags together is a fairly common practice in Java,
and very common in C and C++.

   - Oliver
Roedy Green - 10 Sep 2005 12:12 GMT
>    To get a better understanding of this, study some binary arithmatic and
>boolean operators. ORing flags together is a fairly common practice in Java,
>and very common in C and C++.

see http://mindprod.com/jgloss/masking.html
http://mindprod.com/jgloss/binary.html
http://mindprod.com/jgloss/hex.html
http://mindprod.com/jgloss/precedence.html

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Roedy Green - 08 Sep 2005 05:45 GMT
>so how do you do BOLD AND ITALIC?  obviously this gives me an error..

sum or OR them together

They are essentially constants is a bit map.

See http://mindprod.com/jgloss/font.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



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.