Libraryless. Click here for Pure Java version (8132L/46K).
1 | sclass JOnScreenKeyboard extends JPanel { |
2 | JPanel[] panel; |
3 | JButton[][] button; |
4 | |
5 | event keyPressed(S key); |
6 | |
7 | static final S[][] key = { |
8 | {"Esc", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", |
9 | "F10", "F11", "F12", "PrtSc", "Insert", "Delete", "Home", |
10 | "End", "PgUp", "PgDn"}, {"3\n2", "&", "é", "\"", "'", "(", |
11 | "§", "è", "!", "ç", "à", ")", "-", "BkSpc", "NumLock", "/", |
12 | "*", "-"}, {"Tab", "A", "Z", "E", "R", "T", "Y", "U", "I", |
13 | "O", "P", "^", "$", "Enter", "7", "8", "9", "+"}, |
14 | {"ShiftLock", |
15 | "Q", "S", "D", "F", "G", "H", "J", "K", "L", "M", "ù", "µ", |
16 | "4", "5", "6"}, {"Shift", "<", "W", "X", "C", "V", "B", |
17 | "N", ",", ";", ":", "=", "Shift", "Up", "1", "2", "3", "Enter"}, |
18 | {"Ctrl", "Fn", "Win", "Alt", "Space", "AltGr", "Context", |
19 | "Ctrl", "Left", "Down", "Right", "0", "."} |
20 | }; |
21 | |
22 | *() { |
23 | init(); |
24 | } |
25 | |
26 | void init { |
27 | setLayout(new GridLayout(0, 1)); |
28 | |
29 | panel = new JPanel[6]; |
30 | for (int row = 0; row < key.length; row++) { |
31 | panel[row] = new JPanel(); |
32 | button = new JButton[20][20]; |
33 | for (int column = 0; column < key[row].length; column++) { |
34 | button[row][column] = new JButton(key[row][column]); |
35 | //button[row][column].putClientProperty("column", column); |
36 | //button[row][column].putClientProperty("row", row); |
37 | button[row][column].putClientProperty("key", key[row][column]); |
38 | button[row][column].addActionListener(e -> { |
39 | JButton btn = cast e.getSource(); |
40 | S key = cast btn.getClientProperty("key"); |
41 | _print("JOnScreenKeyboard key pressed: " + key); |
42 | keyPressed(key); |
43 | }); |
44 | panel[row].add(button[row][column]); |
45 | } |
46 | add(panel[row]); |
47 | } |
48 | } |
49 | |
50 | JScrollPane withScrollPane() { |
51 | var sp = jscroll_borderless_center(this); |
52 | onFirstResize(sp, -> scrollToCenter(sp)); |
53 | ret sp; |
54 | } |
55 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035473 |
Snippet name: | JOnScreenKeyboard |
Eternal ID of this version: | #1035473/7 |
Text MD5: | 37ddcabd9601eeff4f1fb92db6f10aab |
Transpilation MD5: | 4cb277c39e62d3fc0cd4003b1ef80ac9 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-22 22:09:17 |
Source code size: | 2026 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 172 / 262 |
Version history: | 6 change(s) |
Referenced in: | [show references] |