-
CSR
-
Resolution: Approved
-
P3
-
None
-
minimal
-
Java API
-
SE
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8330992 | 8-pool | Kazuhisa Takakuri | P3 | Closed | Incomplete |
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;
}
- backported by
-
JDK-8330992 Exception when Tab key moves focus to a JCheckbox with a custom ButtonModel
- Closed
- csr of
-
JDK-8182577 Exception when Tab key moves focus to a JCheckbox with a custom ButtonModel
- Resolved