-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
P4
-
None
-
Affects Version/s: 6
-
Component/s: client-libs
-
x86
-
windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
javax.swing.SwingUtilities.replaceUIInputMap() and javax.swing.SwingUtilities.replaceUIActionMap() do not actually remove previously installed maps as their Javadoc indicates.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JFrame with a single JButton.
2. Create a new javax.swing.ComponentInputMap and add two mappings:
- When VK_ENTER is pressed, fire the "pressed" action.
- When VK_ENTER is released, fire the "released" action.
3. Use SwingUtilities.replaceUIInputMap() to install the map onto the button using the JComponent.WHEN_IN_FOCUSED_WINDOW type.
4. Use SwingUtilities.replaceUIInputMap(), passing in a null third argument, to uninstall the previously installed map.
5. Press and release the ENTER key while the JFrame is focused.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The button should NOT activate because the second call to SwingUtilities.replaceUIInputMap() should have removed the input map that mapped VK_ENTER to the button.
ACTUAL -
The button DOES activate because SwingUtilities.replaceUIInputMap() does not actually do anything to alter the installed input maps.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class UIMapTest {
public static void main(String[] args) {
// Create the test button
JButton button = new JButton("Test");
// Create an input map that maps ENTER to the button
ComponentInputMap map = new ComponentInputMap(button);
map.put(KeyStroke.getKeyStroke("pressed ENTER"), "pressed");
map.put(KeyStroke.getKeyStroke("released ENTER"), "released");
// Add the map
SwingUtilities.replaceUIInputMap(button, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
// Attempt to remove the map
SwingUtilities.replaceUIInputMap(button, JComponent.WHEN_IN_FOCUSED_WINDOW, null);
// Show the frame
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(button);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
java version "1.6.0_05"
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
javax.swing.SwingUtilities.replaceUIInputMap() and javax.swing.SwingUtilities.replaceUIActionMap() do not actually remove previously installed maps as their Javadoc indicates.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a JFrame with a single JButton.
2. Create a new javax.swing.ComponentInputMap and add two mappings:
- When VK_ENTER is pressed, fire the "pressed" action.
- When VK_ENTER is released, fire the "released" action.
3. Use SwingUtilities.replaceUIInputMap() to install the map onto the button using the JComponent.WHEN_IN_FOCUSED_WINDOW type.
4. Use SwingUtilities.replaceUIInputMap(), passing in a null third argument, to uninstall the previously installed map.
5. Press and release the ENTER key while the JFrame is focused.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The button should NOT activate because the second call to SwingUtilities.replaceUIInputMap() should have removed the input map that mapped VK_ENTER to the button.
ACTUAL -
The button DOES activate because SwingUtilities.replaceUIInputMap() does not actually do anything to alter the installed input maps.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class UIMapTest {
public static void main(String[] args) {
// Create the test button
JButton button = new JButton("Test");
// Create an input map that maps ENTER to the button
ComponentInputMap map = new ComponentInputMap(button);
map.put(KeyStroke.getKeyStroke("pressed ENTER"), "pressed");
map.put(KeyStroke.getKeyStroke("released ENTER"), "released");
// Add the map
SwingUtilities.replaceUIInputMap(button, JComponent.WHEN_IN_FOCUSED_WINDOW, map);
// Attempt to remove the map
SwingUtilities.replaceUIInputMap(button, JComponent.WHEN_IN_FOCUSED_WINDOW, null);
// Show the frame
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(button);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
- links to
-
Review(master)
openjdk/jdk/28671