Skip to content

Commit

Permalink
8277497: Last column cell in the JTable row is read as empty cell
Browse files Browse the repository at this point in the history
Backport-of: 70bad89b012eb200ca1e76f384a6e5fb307cf26d
  • Loading branch information
William Kemper authored and GoeLin committed Nov 11, 2022
1 parent 7c664bc commit 03fa471
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/java.desktop/share/classes/javax/swing/JLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1052,6 +1052,10 @@ protected class AccessibleJLabel extends AccessibleJComponent
* @see AccessibleContext#setAccessibleName
*/
public String getAccessibleName() {
return getAccessibleNameCheckIcon(getAccessibleNameImpl());
}

private String getAccessibleNameImpl() {
String name = accessibleName;

if (name == null) {
Expand All @@ -1066,6 +1070,19 @@ public String getAccessibleName() {
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.
*
Expand All @@ -1074,6 +1091,11 @@ public String getAccessibleName() {
* @see AccessibleRole
*/
public AccessibleRole getAccessibleRole() {
String name = getAccessibleNameImpl();
if (((name == null) || name.isEmpty()) &&
(JLabel.this.getIcon() != null)) {
return AccessibleRole.ICON;
}
return AccessibleRole.LABEL;
}

Expand Down

1 comment on commit 03fa471

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.