!7 module FontPlusMinus > DynPrintLog { transient volatile bool active, enlarging; double scale = 1.25; visualize { ret centerAndSouthWithMargins(super.visualize(), jhgrid( jbutton("Font +", r { doIt(true) }), jbutton("Font -", r { doIt(false) }))); } start { dm_requireMouseLogger(); ownResource(vmBus_onMessage('mouseDown, voidfunc(int x, int y, int button) { if (!active) ret; active = false; final JComponent c = optCast(JComponent, componentAtScreenLocation(x, y)); print("Have component: " + c); if (c == null) ret; swing { Font font = scaleFont(c.getFont(), enlarging ? scale : 1/scale); c.setFont(font); print((enlarging ? "Enlarged" : "Shrunk") + " font to " + formatDouble(font.getSize2D(), 1)); } })); } void doIt(bool enlarge) { enlarging = enlarge; print("Please click on a component to " + (enlarge ? "enlarge" : "shrink") + " its font"); set active; } }