< prev index next >

src/com/sun/javatest/tool/FocusMonitor.java

Print this page
rev 145 : 7902237: Fixing raw use of parameterized class
Reviewed-by: jjg


   9  * published by the Free Software Foundation.  Oracle designates this
  10  * particular file as subject to the "Classpath" exception as provided
  11  * by Oracle in the LICENSE file that accompanied this code.
  12  *
  13  * This code is distributed in the hope that it will be useful, but WITHOUT
  14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16  * version 2 for more details (a copy is included in the LICENSE file that
  17  * accompanied this code).
  18  *
  19  * You should have received a copy of the GNU General Public License version
  20  * 2 along with this work; if not, write to the Free Software Foundation,
  21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22  *
  23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 package com.sun.javatest.tool;
  28 
  29 import java.awt.Color;
  30 import java.awt.Component;
  31 import java.awt.Container;
  32 import java.awt.FocusTraversalPolicy;
  33 import java.awt.Frame;
  34 import java.awt.GridBagConstraints;
  35 import java.awt.GridBagLayout;
  36 import java.awt.KeyboardFocusManager;
  37 import java.awt.Window;
  38 import java.awt.event.ActionEvent;
  39 import java.awt.event.WindowAdapter;
  40 import java.awt.event.WindowEvent;
  41 import java.beans.PropertyChangeEvent;
  42 import java.beans.PropertyChangeListener;
  43 import java.io.*;
  44 import java.nio.charset.StandardCharsets;
  45 import java.util.Iterator;
  46 import java.util.Set;
  47 import java.util.Vector;
  48 import java.beans.PropertyChangeListener;
  49 import javax.accessibility.AccessibleContext;
  50 import javax.swing.AbstractAction;
  51 import javax.swing.Action;
  52 import javax.swing.ActionMap;
  53 import javax.swing.BorderFactory;
  54 import javax.swing.InputMap;
  55 import javax.swing.JButton;
  56 import javax.swing.JCheckBoxMenuItem;
  57 import javax.swing.JComponent;


 381 
 382         if (rootAncestor != null)
 383             return rootAncestor;
 384 
 385         Container window =
 386             (c instanceof Container) ? ((Container)c) : c.getParent();
 387         while (window != null && !(window instanceof Window)) {
 388             window = window.getParent();
 389         }
 390         if (window == null)
 391             return null;
 392 
 393         Component toFocus = window.getFocusTraversalPolicy().getDefaultComponent(window);
 394         return toFocus;
 395     }
 396 
 397     private static String getKeysString(Component c, int mode) {
 398         if (c == null)
 399             return null;
 400 
 401         Set s = c.getFocusTraversalKeys(mode);
 402         StringBuffer sb = new StringBuffer();
 403         for (Iterator iter = s.iterator(); iter.hasNext(); ) {
 404             if (sb.length() > 0)
 405                 sb.append(", ");
 406             sb.append(iter.next());
 407         }
 408         if (!c.areFocusTraversalKeysSet(mode))
 409             sb.append(" (inherited)");
 410         return sb.toString();
 411     }
 412 
 413     private static String getPath(Component c) {
 414         StringBuffer sb = new StringBuffer();
 415         appendPath(sb, c);
 416         return sb.toString();
 417     }
 418 
 419     private static void appendPath(StringBuffer sb, Component c) {
 420         Container p = c.getParent();
 421         if (p != null)
 422             appendPath(sb, p);
 423         sb.append('/');




   9  * published by the Free Software Foundation.  Oracle designates this
  10  * particular file as subject to the "Classpath" exception as provided
  11  * by Oracle in the LICENSE file that accompanied this code.
  12  *
  13  * This code is distributed in the hope that it will be useful, but WITHOUT
  14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  16  * version 2 for more details (a copy is included in the LICENSE file that
  17  * accompanied this code).
  18  *
  19  * You should have received a copy of the GNU General Public License version
  20  * 2 along with this work; if not, write to the Free Software Foundation,
  21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  22  *
  23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  24  * or visit www.oracle.com if you need additional information or have any
  25  * questions.
  26  */
  27 package com.sun.javatest.tool;
  28 
  29 import java.awt.*;








  30 import java.awt.event.ActionEvent;
  31 import java.awt.event.WindowAdapter;
  32 import java.awt.event.WindowEvent;
  33 import java.beans.PropertyChangeEvent;
  34 import java.beans.PropertyChangeListener;
  35 import java.io.*;
  36 import java.nio.charset.StandardCharsets;
  37 import java.util.Iterator;
  38 import java.util.Set;
  39 import java.util.Vector;
  40 import java.beans.PropertyChangeListener;
  41 import javax.accessibility.AccessibleContext;
  42 import javax.swing.AbstractAction;
  43 import javax.swing.Action;
  44 import javax.swing.ActionMap;
  45 import javax.swing.BorderFactory;
  46 import javax.swing.InputMap;
  47 import javax.swing.JButton;
  48 import javax.swing.JCheckBoxMenuItem;
  49 import javax.swing.JComponent;


 373 
 374         if (rootAncestor != null)
 375             return rootAncestor;
 376 
 377         Container window =
 378             (c instanceof Container) ? ((Container)c) : c.getParent();
 379         while (window != null && !(window instanceof Window)) {
 380             window = window.getParent();
 381         }
 382         if (window == null)
 383             return null;
 384 
 385         Component toFocus = window.getFocusTraversalPolicy().getDefaultComponent(window);
 386         return toFocus;
 387     }
 388 
 389     private static String getKeysString(Component c, int mode) {
 390         if (c == null)
 391             return null;
 392 
 393         Set<AWTKeyStroke> s = c.getFocusTraversalKeys(mode);
 394         StringBuffer sb = new StringBuffer();
 395         for (Iterator<AWTKeyStroke> iter = s.iterator(); iter.hasNext(); ) {
 396             if (sb.length() > 0)
 397                 sb.append(", ");
 398             sb.append(iter.next());
 399         }
 400         if (!c.areFocusTraversalKeysSet(mode))
 401             sb.append(" (inherited)");
 402         return sb.toString();
 403     }
 404 
 405     private static String getPath(Component c) {
 406         StringBuffer sb = new StringBuffer();
 407         appendPath(sb, c);
 408         return sb.toString();
 409     }
 410 
 411     private static void appendPath(StringBuffer sb, Component c) {
 412         Container p = c.getParent();
 413         if (p != null)
 414             appendPath(sb, p);
 415         sb.append('/');


< prev index next >