src/share/classes/java/awt/event/InputEvent.java

Print this page

        

*** 28,37 **** --- 28,38 ---- import java.awt.Event; import java.awt.Component; import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.util.Arrays; + import java.util.StringJoiner; import sun.awt.AWTAccessor; import sun.awt.AWTPermissions; import sun.util.logging.PlatformLogger;
*** 510,550 **** * modifier keys and mouse buttons that were held down * during the event. * @since 1.4 */ public static String getModifiersExText(int modifiers) { ! StringBuilder buf = new StringBuilder(); if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { ! buf.append(Toolkit.getProperty("AWT.meta", "Meta")); ! buf.append("+"); } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { ! buf.append(Toolkit.getProperty("AWT.control", "Ctrl")); ! buf.append("+"); } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { ! buf.append(Toolkit.getProperty("AWT.alt", "Alt")); ! buf.append("+"); } if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { ! buf.append(Toolkit.getProperty("AWT.shift", "Shift")); ! buf.append("+"); } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { ! buf.append(Toolkit.getProperty("AWT.altGraph", "Alt Graph")); ! buf.append("+"); } int buttonNumber = 1; for (int mask : InputEvent.BUTTON_DOWN_MASK){ if ((modifiers & mask) != 0) { ! buf.append(Toolkit.getProperty("AWT.button"+buttonNumber, "Button"+buttonNumber)); ! buf.append("+"); } buttonNumber++; } - if (buf.length() > 0) { - buf.setLength(buf.length()-1); // remove trailing '+' - } return buf.toString(); } } --- 511,542 ---- * modifier keys and mouse buttons that were held down * during the event. * @since 1.4 */ public static String getModifiersExText(int modifiers) { ! StringJoiner buf = new StringJoiner("+"); if ((modifiers & InputEvent.META_DOWN_MASK) != 0) { ! buf.add(Toolkit.getProperty("AWT.meta", "Meta")); } if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { ! buf.add(Toolkit.getProperty("AWT.control", "Ctrl")); } if ((modifiers & InputEvent.ALT_DOWN_MASK) != 0) { ! buf.add(Toolkit.getProperty("AWT.alt", "Alt")); } if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { ! buf.add(Toolkit.getProperty("AWT.shift", "Shift")); } if ((modifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) { ! buf.add(Toolkit.getProperty("AWT.altGraph", "Alt Graph")); } int buttonNumber = 1; for (int mask : InputEvent.BUTTON_DOWN_MASK){ if ((modifiers & mask) != 0) { ! buf.add(Toolkit.getProperty("AWT.button" + buttonNumber, "Button" + buttonNumber)); } buttonNumber++; } return buf.toString(); } }