Libraryless. Click here for Pure Java version (14734L/102K).
1 | !7 |
2 | |
3 | module FontPlusMinus > DynPrintLog { |
4 | transient volatile bool active, enlarging; |
5 | double scale = 1.25; |
6 | |
7 | visualize { |
8 | ret centerAndSouthWithMargins(super.visualize(), jhgrid( |
9 | jbutton("Font +", r { doIt(true) }), |
10 | jbutton("Font -", r { doIt(false) }))); |
11 | } |
12 | |
13 | start { |
14 | dm_requireMouseLogger(); |
15 | ownResource(vmBus_onMessage('mouseDown, voidfunc(int x, int y, int button) { |
16 | if (!active) ret; |
17 | active = false; |
18 | final JComponent c = optCast(JComponent, componentAtScreenLocation(x, y)); |
19 | print("Have component: " + c); |
20 | if (c == null) ret; |
21 | swing { |
22 | Font font = scaleFont(c.getFont(), enlarging ? scale : 1/scale); |
23 | c.setFont(font); |
24 | print((enlarging ? "Enlarged" : "Shrunk") + " font to " + formatDouble(font.getSize2D(), 1)); |
25 | } |
26 | })); |
27 | } |
28 | |
29 | void doIt(bool enlarge) { |
30 | enlarging = enlarge; |
31 | print("Please click on a component to " + (enlarge ? "enlarge" : "shrink") + " its font"); |
32 | set active; |
33 | } |
34 | } |
Began life as a copy of #1019642
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1019643 |
Snippet name: | Font Plus/Minus (enlarge/shrink font size of components by clicking on them) |
Eternal ID of this version: | #1019643/6 |
Text MD5: | 798d7478d374ee17e8372956cb10aa43 |
Transpilation MD5: | a9c29ae4df3e89ef886457d0de7e6b5c |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-11-17 00:51:27 |
Source code size: | 1031 bytes / 34 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 319 / 6675 |
Version history: | 5 change(s) |
Referenced in: | [show references] |