sclass JOnScreenKeyboard extends JPanel { JPanel[] panel; JButton[][] button; event keyPressed(S key); static final S[][] key = { {"Esc", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "PrtSc", "Insert", "Delete", "Home", "End", "PgUp", "PgDn"}, {"3\n2", "&", "é", "\"", "'", "(", "§", "è", "!", "ç", "à", ")", "-", "BkSpc", "NumLock", "/", "*", "-"}, {"Tab", "A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "^", "$", "Enter", "7", "8", "9", "+"}, {"ShiftLock", "Q", "S", "D", "F", "G", "H", "J", "K", "L", "M", "ù", "µ", "4", "5", "6"}, {"Shift", "<", "W", "X", "C", "V", "B", "N", ",", ";", ":", "=", "Shift", "Up", "1", "2", "3", "Enter"}, {"Ctrl", "Fn", "Win", "Alt", "Space", "AltGr", "Context", "Ctrl", "Left", "Down", "Right", "0", "."} }; *() { init(); } void init { setLayout(new GridLayout(0, 1)); panel = new JPanel[6]; for (int row = 0; row < key.length; row++) { panel[row] = new JPanel(); button = new JButton[20][20]; for (int column = 0; column < key[row].length; column++) { button[row][column] = new JButton(key[row][column]); //button[row][column].putClientProperty("column", column); //button[row][column].putClientProperty("row", row); button[row][column].putClientProperty("key", key[row][column]); button[row][column].addActionListener(e -> { JButton btn = cast e.getSource(); S key = cast btn.getClientProperty("key"); _print("JOnScreenKeyboard key pressed: " + key); keyPressed(key); }); panel[row].add(button[row][column]); } add(panel[row]); } } JScrollPane withScrollPane() { var sp = jscroll_borderless_center(this); onFirstResize(sp, -> scrollToCenter(sp)); ret sp; } }