Skip to content

Commit

Permalink
8274634: Use String.equals instead of String.compareTo in java.desktop
Browse files Browse the repository at this point in the history
Reviewed-by: serb, pbansal
  • Loading branch information
turbanoff authored and Pankaj Bansal committed Oct 4, 2021
1 parent 3281102 commit 6726c59
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
@@ -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
Expand Down Expand Up @@ -115,19 +115,19 @@ public void propertyChange(PropertyChangeEvent e) {
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();
Expand Down Expand Up @@ -167,12 +167,12 @@ public void propertyChange(PropertyChangeEvent e) {
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 ||
Expand Down
4 changes: 2 additions & 2 deletions src/java.desktop/share/classes/javax/swing/JList.java
Expand Up @@ -2947,7 +2947,7 @@ public void propertyChange(PropertyChangeEvent e) {
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);
Expand All @@ -2957,7 +2957,7 @@ public void propertyChange(PropertyChangeEvent e) {
}

// 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);
Expand Down
8 changes: 4 additions & 4 deletions src/java.desktop/share/classes/javax/swing/JTable.java
Expand Up @@ -6756,7 +6756,7 @@ public void propertyChange(PropertyChangeEvent e) {
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);
Expand All @@ -6766,7 +6766,7 @@ public void propertyChange(PropertyChangeEvent e) {
}

// 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
Expand Down Expand Up @@ -6797,7 +6797,7 @@ public void propertyChange(PropertyChangeEvent e) {

// 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;
Expand All @@ -6811,7 +6811,7 @@ public void propertyChange(PropertyChangeEvent e) {
}

// 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);
Expand Down

1 comment on commit 6726c59

@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.