• 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

how to set the font type for a "string"

 
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there,

Does anyone know how to change the color and font for a String?

I'd like my result to be like:

System.out.println("Due Date:" + record.getDueDate() ");

how can I make the record.getDueDate() with .setFont() ???

Thanks for any help
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.out.println prints to a DOS window that is always 2 colors (background and text) and a standard font.
----
If you were to print using a graphics object on something that could produce Fonts and colors you would do this:

Create a new Font Object with the desired characteristics (see Java API for Font constructors).

Set the font of your graphics object using the setFont method and your newly-created Font object.

Set the color of your graphics object using the setColor method and a static object of the Color class (see classes Graphics and Color in the Java API as needed).

Now print using the graphics object.
 
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at the working with text and fonts tutorial
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic