0

I have a font variable static public Font bold_13 = new Font("Arial", Font.BOLD, 13); which is set to text. Now based on some condition I need to change the style of the font.

One possible solution which i found was

field.setFont(field.getFont().deriveFont(Font.ITALIC));

I cant use the same in my application because I dont know the field when i am changing the style. So I cant use like field.setFont!

Andrew Thompson
  • 166,747
  • 40
  • 210
  • 420
MRavindran
  • 427
  • 2
  • 9
  • 24
  • possible duplicate of [Changing Font Style when Clicking on a JButton Java](http://stackoverflow.com/questions/8679088/changing-font-style-when-clicking-on-a-jbutton-java) – jlopez Jul 27 '15 at 10:04
  • For all fields? Or do you rather wish to retrieve which field is concerned. From most listeners, the `event.getSource()` will provide that info. – Joop Eggen Jul 27 '15 at 10:08
  • I mentioned in my question that I already saw the solution which you have pointed out but I can not use the same in my application. – MRavindran Jul 27 '15 at 10:08
  • *"..I dont know the field.."* Why not? For better help sooner, post a [MCVE] or [Short, Self Contained, Correct Example](http://www.sscce.org/). – Andrew Thompson Jul 27 '15 at 14:49

0 Answers0