8277497: Last column cell in the JTAble row is read as empty cell

Reviewed-by: ant, kizune, pbansal
This commit is contained in:
Artem Semenov 2021-12-06 17:39:43 +00:00
parent 5045eb538b
commit 70bad89b01

View File

@ -1075,6 +1075,10 @@ public class JLabel extends JComponent implements SwingConstants, Accessible
* @see AccessibleContext#setAccessibleName
*/
public String getAccessibleName() {
return getAccessibleNameCheckIcon(getAccessibleNameImpl());
}
private String getAccessibleNameImpl() {
String name = accessibleName;
if (name == null) {
@ -1089,6 +1093,19 @@ public class JLabel extends JComponent implements SwingConstants, Accessible
return name;
}
private String getAccessibleNameCheckIcon(String name) {
if (((name == null) || name.isEmpty()) &&
(JLabel.this.getIcon() != null)) {
if (JLabel.this.getIcon() instanceof Accessible) {
AccessibleContext ac = ((Accessible) JLabel.this.getIcon()).getAccessibleContext();
if (ac != null) {
name = ac.getAccessibleName();
}
}
}
return name;
}
/**
* Get the role of this object.
*
@ -1097,6 +1114,11 @@ public class JLabel extends JComponent implements SwingConstants, Accessible
* @see AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
String name = getAccessibleNameImpl();
if (((name == null) || name.isEmpty()) &&
(JLabel.this.getIcon() != null)) {
return AccessibleRole.ICON;
}
return AccessibleRole.LABEL;
}