-
CSR
-
Resolution: Unresolved
-
P3
-
None
-
minimal
-
Java API
-
SE
Summary
Add getModel() method to ButtonModel interface.
Problem
As stated in JDK-8182577, when a custom ButtonModel is used and keyboard focus is moved by pressing TAB key, then in LayoutFocusTraversalPolicy.accept() method, it typecasts buttonmodel object to JToggleButton.ToggleButtonModel which results in ClassCastException.
Solution
Added getModel() method to ButtonModel interface [src/java.desktop/share/classes/javax/swing/ButtonModel.java] would result in custom ButtonModel to implement this method. Also, LayoutFocusTraversalPolicy.accept() has been modified to store the model object as ButtonModel object instead of wrongly assuming as JToggleButton.ToggleButtonModel. Review thread : http://mail.openjdk.java.net/pipermail/swing-dev/2017-June/007521.html
Specification
/**
* Returns the group that the button belongs to.
* Normally used with radio buttons, which are mutually
* exclusive within their group.
*
* @implSpec By default, this method returns {@code null}.
* Subclasses should return the group set by setGroup().
*
* @return the <code>ButtonGroup</code> that the button belongs to
* @since 10
*/
default ButtonGroup getGroup() {
return null;
}
- csr of
-
JDK-8337619 Exception when Tab key moves focus to a JCheckbox with a custom ButtonModel
-
- Open
-