Change font size at runtime with slider for entire Java Swing application with Nimbus L&F (Linux)
The following approach does not work for me. I don't know if it is due to the fact that I'm using Nimbus L&F, or maybe it is because I'm not redrawing the components properly after the fact, or maybe it is because my app is a Netbeans SingleFrameApplication (boy, do I regret that decision) or maybe I have overlooked something obvious. I have read a couple dozen posts on this topic and I have experimented with a lot of various approaches but I have not found anything that will accomplish the task.

I would like the font size changes to apply to any components already created as well as any that get created subsequently (such as new dialogs, etc.).

(I plan to save the font size to the application's properties so the next instance will start up with the chosen font size. I would also like to implement themes -- such as for users with low vision -- so maybe there is an overall better approach.)

    public static void adjustGlobalFontSize(Float percentChange) {

		Enumeration keySet = UIManager.getDefaults().keys();
		while (keySet.hasMoreElements()) {
			Object key = keySet.nextElement();
			Object value = UIManager.get(key);
			if (value instanceof Font) {
				Font f = (Font)value;
				Float sizef = f.getSize2D() * percentChange;
				int size = Math.round(sizef);				
				FontUIResource resf = new FontUIResource(f.getName(), f.getStyle(), size);
				UIManager.put(key, resf);
			}
		}
		SwingUtilities.updateComponentTreeUI(MyApp.getApplication().getMainFrame());

	}
Change font size at runtime with slider for entire Java Swing application with Nimbus L&F (Linux)
===

The following approach does not work for me. I don't know if it is due to the fact that I'm using Nimbus L&F, or maybe it is because I'm not redrawing the components properly after the fact, or maybe it is because my app is a Netbeans SingleFrameApplication (boy, do I regret that decision) or maybe I have overlooked something obvious. I have read a couple dozen posts on this topic and I have experimented with a lot of various approaches but I have not found anything that will accomplish the task.

I would like the font size changes to apply to any components already created as well as any that get created subsequently (such as new dialogs, etc.).

(I plan to save the font size to the application's properties so the next instance will start up with the chosen font size. I would also like to implement themes -- such as for users with low vision -- so maybe there is an overall better approach.)

    public static void adjustGlobalFontSize(Float percentChange) {

		Enumeration keySet = UIManager.getDefaults().keys();
		while (keySet.hasMoreElements()) {
			Object key = keySet.nextElement();
			Object value = UIManager.get(key);
			if (value instanceof Font) {
				Font f = (Font)value;
				Float sizef = f.getSize2D() * percentChange;
				int size = Math.round(sizef);				
				FontUIResource resf = new FontUIResource(f.getName(), f.getStyle(), size);
				UIManager.put(key, resf);
			}
		}
		SwingUtilities.updateComponentTreeUI(MyApp.getApplication().getMainFrame());

	}