On Fri, 27 Jan 2023 10:26:10 GMT, Prasanta Sadhukhan <[email protected]> wrote:
> When the Action.SELECTED_KEY property action is assigned to ToggleButton and > an accelerator key binding is mapped to the action, then pressing the > accelerator key binding does not toggle the toggle button. > This is because SwingUtilities.notifyAction does not fire itemStateChanged > event for such action related to SELECTED_KEY. > Fix is to get the Action.SELECTED_KEY command/action and fire > itemStateChanged Event via JToggleButton.setSelected() call to notify > propertyChange listener of the toggled property. Changes requested by [email protected] (no known OpenJDK username). src/java.desktop/share/classes/javax/swing/SwingUtilities.java line 1814: > 1812: modifiers)); > 1813: if (event.getSource() instanceof JToggleButton) { > 1814: JToggleButton tb = (JToggleButton)event.getSource(); Please use a pattern variable here: Suggestion: if (event.getSource() instanceof JToggleButton tb) { ------------- PR: https://git.openjdk.org/jdk/pull/12253
