Changeset 4930 in josm
- Timestamp:
- 2012-02-14T13:26:15+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PrefJPanel.java
r4929 r4930 11 11 12 12 import java.awt.event.KeyEvent; 13 import java.lang.reflect.Field; 13 14 import java.util.ArrayList; 14 15 import java.util.LinkedHashMap; … … 106 107 Map<Integer, String> list = new LinkedHashMap<Integer, String>(); 107 108 String unknown = Toolkit.getProperty("AWT.unknown", "Unknown"); 108 // I hate this, but I found no alternative... 109 for (int i = 0; i < 65534; i++) { 110 String s = KeyEvent.getKeyText(i); 111 if (s != null && s.length() > 0 && !s.contains(unknown)) { 112 list.put(Integer.valueOf(i), s); 113 //System.out.println(i+": "+s); 109 // Assume all known keys are declared in KeyEvent as "public static int VK_*" 110 for (Field field : KeyEvent.class.getFields()) { 111 if (field.getName().startsWith("VK_")) { 112 try { 113 int i = field.getInt(null); 114 String s = KeyEvent.getKeyText(i); 115 if (s != null && s.length() > 0 && !s.contains(unknown)) { 116 list.put(Integer.valueOf(i), s); 117 //System.out.println(i+": "+s); 118 } 119 } catch (Exception e) { 120 e.printStackTrace(); 121 } 114 122 } 115 123 }
Note:
See TracChangeset
for help on using the changeset viewer.