• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make String variable in Bold or Italic ?  RSS feed

 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

Can anybody suggest ,Is there any way to make String Variable in Bold or Italic ?

I have say below code :

String tempString = "Test";

I wanted to make this "Test" in bold .

Thanks in advance

- Chetan
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can only make the string bold when you write it out to somewhere. How you do it depends on where you write it to and it may not always be possible if where you output it to doesn't support bold text.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12562
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A key concept in much of the IS world is that you separate the DATA from the PRESENTATION. Bold or italics are part of the presentation. A String can only hold the data.
 
Ramesh Pramuditha Rathnayake
Ranch Hand
Posts: 178
2
Java MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String object cannot store whether the text is bold, italic or regular. It has only a character array.

Bold or Italic means a visual effect. Therefore you have to print the text on a JLabel, JButton, JList, or any component to make it bold or whatever..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!