8274634: Use String.equals instead of String.compareTo in java.desktop

Reviewed-by: serb, pbansal
This commit is contained in:
Andrey Turbanov 2021-10-04 10:27:20 +00:00 committed by Pankaj Bansal
parent 32811026ce
commit 6726c592ed
3 changed files with 15 additions and 15 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -115,19 +115,19 @@ class CAccessible extends CFRetainedResource implements Accessible {
if ( ptr != 0 ) {
Object newValue = e.getNewValue();
Object oldValue = e.getOldValue();
if (name.compareTo(ACCESSIBLE_CARET_PROPERTY) == 0) {
if (name.equals(ACCESSIBLE_CARET_PROPERTY)) {
selectedTextChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_TEXT_PROPERTY) == 0) {
} else if (name.equals(ACCESSIBLE_TEXT_PROPERTY)) {
valueChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_SELECTION_PROPERTY) == 0) {
} else if (name.equals(ACCESSIBLE_SELECTION_PROPERTY)) {
selectionChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_TABLE_MODEL_CHANGED) == 0) {
} else if (name.equals(ACCESSIBLE_TABLE_MODEL_CHANGED)) {
valueChanged(ptr);
} else if (name.compareTo(ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) == 0 ) {
} else if (name.equals(ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY)) {
if (newValue instanceof AccessibleContext) {
activeDescendant = (AccessibleContext)newValue;
}
} else if (name.compareTo(ACCESSIBLE_STATE_PROPERTY) == 0) {
} else if (name.equals(ACCESSIBLE_STATE_PROPERTY)) {
AccessibleContext thisAC = accessible.getAccessibleContext();
AccessibleRole thisRole = thisAC.getAccessibleRole();
Accessible parentAccessible = thisAC.getAccessibleParent();
@ -167,12 +167,12 @@ class CAccessible extends CFRetainedResource implements Accessible {
if (thisRole == AccessibleRole.CHECK_BOX) {
valueChanged(ptr);
}
} else if (name.compareTo(ACCESSIBLE_NAME_PROPERTY) == 0) {
} else if (name.equals(ACCESSIBLE_NAME_PROPERTY)) {
//for now trigger only for JTabbedPane.
if (e.getSource() instanceof JTabbedPane) {
titleChanged(ptr);
}
} else if (name.compareTo(ACCESSIBLE_VALUE_PROPERTY) == 0) {
} else if (name.equals(ACCESSIBLE_VALUE_PROPERTY)) {
AccessibleRole thisRole = accessible.getAccessibleContext()
.getAccessibleRole();
if (thisRole == AccessibleRole.SLIDER ||

View File

@ -2947,7 +2947,7 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
Object newValue = e.getNewValue();
// re-set listData listeners
if (name.compareTo("model") == 0) {
if (name.equals("model")) {
if (oldValue != null && oldValue instanceof ListModel) {
((ListModel) oldValue).removeListDataListener(this);
@ -2957,7 +2957,7 @@ public class JList<E> extends JComponent implements Scrollable, Accessible
}
// re-set listSelectionModel listeners
} else if (name.compareTo("selectionModel") == 0) {
} else if (name.equals("selectionModel")) {
if (oldValue != null && oldValue instanceof ListSelectionModel) {
((ListSelectionModel) oldValue).removeListSelectionListener(this);

View File

@ -6756,7 +6756,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
Object newValue = e.getNewValue();
// re-set tableModel listeners
if (name.compareTo("model") == 0) {
if (name.equals("model")) {
if (oldValue != null && oldValue instanceof TableModel) {
((TableModel) oldValue).removeTableModelListener(this);
@ -6766,7 +6766,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
}
// re-set selectionModel listeners
} else if (name.compareTo("selectionModel") == 0) {
} else if (name.equals("selectionModel")) {
Object source = e.getSource();
if (source == JTable.this) { // row selection model
@ -6797,7 +6797,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
// re-set columnModel listeners
// and column's selection property listener as well
} else if (name.compareTo("columnModel") == 0) {
} else if (name.equals("columnModel")) {
if (oldValue != null && oldValue instanceof TableColumnModel) {
TableColumnModel tcm = (TableColumnModel) oldValue;
@ -6811,7 +6811,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
}
// re-se cellEditor listeners
} else if (name.compareTo("tableCellEditor") == 0) {
} else if (name.equals("tableCellEditor")) {
if (oldValue != null && oldValue instanceof TableCellEditor) {
((TableCellEditor) oldValue).removeCellEditorListener(this);