0

I was working on some of my project and i faced this problem,i want to print name in bold and txt as plain. Here TF1 and TF2 are JTextFields. TA1 is JTextArea. I will glad if you help me out. Thanks!

String name=TF1.getText();
String txt=TF2.getText();
TA1.append(name+":"+txt+"\n");
Jongware
  • 22,200
  • 8
  • 54
  • 100
  • 1
    `JTextArea` is not able to change the font for individual parts of the string. You need to use some other component. In Java some Components support HTML formatting like `JLable` or `JEditorPane`. – Timothy Truckle Mar 04 '17 at 10:30
  • If you have to use a JTextArea, you could use unicode as a *hack*. Unicode has code points for [bold, italic, ... versions](https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols) of the alphabet. You just need to write a function that converts a part of your string to its bold equivalent. – Socowi Mar 04 '17 at 12:33

0 Answers0