Is there any default way in Java to translate KeyStroke to readable String except manual parsing?
Java
KeyStroke
String
KeyStroke ke = KeyStroke.getKeyStroke("ctrl released 1"); System.out.println(ke.toString()) Print result: ctrl released 1 Expected: Ctrl+1
From Java Swing API:
Java Swing API
KeyStroke accelerator = b.getAccelerator(); String acceleratorText = ""; if (accelerator != null) { int modifiers = accelerator.getModifiers(); if (modifiers > 0) { acceleratorText = KeyEvent.getKeyModifiersText(modifiers); acceleratorText += "+"; } acceleratorText += KeyEvent.getKeyText(accelerator.getKeyCode()); }
@mKorbel, U're wrong and groundless saying that it isn't a part of defaults
From
Java Swing API
:@mKorbel, U're wrong and groundless saying that it isn't a part of defaults