changeset 551:4ccac6957211

6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08 Summary: acquire the first|last components only when the key is a traversal key Reviewed-by: ant
author dcherepanov
date Thu, 26 Jun 2008 14:23:25 +0400
parents 59e34bb65340
children d2165ac39874
files src/share/classes/sun/awt/EmbeddedFrame.java
diffstat 1 files changed, 16 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/sun/awt/EmbeddedFrame.java	Mon Jun 23 16:03:25 2008 +0400
+++ b/src/share/classes/sun/awt/EmbeddedFrame.java	Thu Jun 26 14:23:25 2008 +0400
@@ -257,21 +257,27 @@
         Set toTest;
         Component currentFocused = e.getComponent();
 
-        Component last = getFocusTraversalPolicy().getLastComponent(this);
         toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
-        if (toTest.contains(stroke) && (currentFocused == last || last == null)) {
-            if (traverseOut(FORWARD)) {
-                e.consume();
-                return true;
+        if (toTest.contains(stroke)) {
+            // 6581899: performance improvement for SortingFocusTraversalPolicy
+            Component last = getFocusTraversalPolicy().getLastComponent(this);
+            if (currentFocused == last || last == null) {
+                if (traverseOut(FORWARD)) {
+                    e.consume();
+                    return true;
+                }
             }
         }
 
-        Component first = getFocusTraversalPolicy().getFirstComponent(this);
         toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
-        if (toTest.contains(stroke) && (currentFocused == first || first == null)) {
-            if (traverseOut(BACKWARD)) {
-                e.consume();
-                return true;
+        if (toTest.contains(stroke)) {
+            // 6581899: performance improvement for SortingFocusTraversalPolicy
+            Component first = getFocusTraversalPolicy().getFirstComponent(this);
+            if (currentFocused == first || first == null) {
+                if (traverseOut(BACKWARD)) {
+                    e.consume();
+                    return true;
+                }
             }
         }
         return false;