• 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

customise string?

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for example.
System.out.print("Bold");

may i know how to customise the string. make bold or change its font type or size, etc.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In short, it usually depends on where your output is going. For example, if you are outputting to HTML, you just surround the text with <B></B> tags to make it bold, as well <font> tags for sizing and other options. If you are using Swing, there are a wide variety of libraries for formatting.

You can do some formatting of data types, such as truncating decimals to 2 digits using printf() the Java Util Formatter API.

For simple PrintWriters, such as System.out as you listed, I do not believe you can control the format other than what I have listed above.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using System.out.println() you cannot easily make bold or italic text because this is assumed to go a text-based console. If you need different fonts, you will probably need to use a GUI or some graphics library that supports fonts.

Layne
 
Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic