Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set the font type for a "string"

 
Peter Primrose
Ranch Hand
Posts: 755
  • Mark post as helpful
  • send pies
  • 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
 
Elouise Kivineva
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • 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.
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the working with text and fonts tutorial
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic