-1

I am making a project based on Java swing as it is a GUI based project. I need to be able to change Font of my Entire project with another GUI Frame. Like If I made a GUI to select any font from the JCombobox with a Submit button Then after selecting a font for eg. Arial all the Frames fonts containing JLabel &JTextfield & every other swing component

Should change its font to Arial

I searched over the Internet but was not able to find anything specific I found a bit about

Config File For Java

I also have searched for PropertyChangeListener but it kind of did not work for me to change the fonts of all my frames as it was complicated.

Could anyone help me solve my problem

Arghavan
  • 1,125
  • 1
  • 11
  • 17
  • 1
    You mean something [like this](http://stackoverflow.com/questions/34149453/java-swing-application-too-small-in-hidpi-computers/34152675#34152675)? – MadProgrammer Feb 27 '17 at 07:56
  • 2
    See also [*Modifying the Look and Feel*](https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/index.html). – trashgod Feb 27 '17 at 07:57
  • @MadProgrammer din't get you – Kaustubh Gurudatt Kamat Feb 27 '17 at 07:59
  • @trashgod thank you but I am not looking to change LookAndFeel of the GUI . I only want to change the font of Components – Kaustubh Gurudatt Kamat Feb 27 '17 at 08:00
  • @KaustubhGurudattKamat There's a link in that comment, to a runnable example which I believe demonstrates what you're asking, click and have a look – MadProgrammer Feb 27 '17 at 08:03
  • Like in paint application there is Text font selecting comboBox . We select a **Font** and then write with that font. But instead of writing I want to change Font of Components in my project. – Kaustubh Gurudatt Kamat Feb 27 '17 at 08:03
  • 1
    1) This is best addressed in using a custom Look and Feel. 2) Don't presume Arial will be available on all OS. Instead use `Font.SANS_SERIF` which should result in Arial on Windows, Helvetica on OS X and the default undecorated font on *nix systems. 3) See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/q/9554636/418556) – Andrew Thompson Feb 27 '17 at 08:34
  • @MadProgrammer yeah kind of same only changing font for all frames there are in project . N thank you this will help me a lot too. – Kaustubh Gurudatt Kamat Feb 27 '17 at 08:40
  • @AndrewThompson Okies me try and see that thank you – Kaustubh Gurudatt Kamat Feb 27 '17 at 09:14
  • @KaustubhGurudattKamat Well, that example would update ALL UI components within the given JVM, so it won't matter how many frames you have it, they'd all be updated – MadProgrammer Feb 27 '17 at 10:20
  • @MadProgrammer Thank You. Me trying out the program to change fonts. I have taken 5 different fonts to be able to change. In all frames. Starting with a default **Georgia** font – Kaustubh Gurudatt Kamat Feb 27 '17 at 11:07

1 Answers1

0

You should look at the tutorial about PropertyChangeListeners.

FredK
  • 4,094
  • 1
  • 9
  • 11
  • It's good. Actually I checked this site before. And I tried to do some coding ,based on the **PropertyChangeListener** too. But it only complicated the Project. Is it possible to do it in more simple and elegant way. As Coding should be Kept Simple. And still get my job done – Kaustubh Gurudatt Kamat Feb 27 '17 at 07:42
  • *"Actually I checked this site before."* The question should detail what you have already tried & why it failed to work. Please edit the question to include all relevant information. If you could not be bothered giving us enough information to help, why should we bother trying? – Andrew Thompson Feb 27 '17 at 08:37
  • @AndrewThompson Sorry for that but me first of all did not understand what and how to use it perfectly. Me did tried it out after searching but did not got my result. So me though it would not work. Or may be there is some other way to do it. As I am a newbie in stackOverflow I apologise for an incomplete Question. I will update it in a moment – Kaustubh Gurudatt Kamat Feb 27 '17 at 08:43
  • @AndrewThompson and as for y it did not work. I really have no idea about it. Sorry – Kaustubh Gurudatt Kamat Feb 27 '17 at 08:44