src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/Translator.java
author dholmes
Sun, 08 Jul 2018 20:00:46 -0400
changeset 51005 0083d474b0e1
parent 47216 71c04702a3d5
child 52252 de9486d74a74
permissions -rw-r--r--
8205966: [testbug] New Nestmates JDI test times out with Xcomp on sparc Reviewed-by: mikael, sspitsyn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29883
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     1
/*
37571
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
     2
 * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
29883
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     4
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    10
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    15
 * accompanied this code).
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    16
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    20
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    23
 * questions.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    24
 */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    25
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    26
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    27
package com.sun.java.accessibility.util;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    28
37571
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    29
import com.sun.java.accessibility.util.internal.*;
29883
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    30
import java.beans.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    31
import java.util.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    32
import java.awt.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    33
import java.awt.event.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    34
// Do not import Swing classes.  This module is intended to work
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    35
// with both Swing and AWT.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    36
// import javax.swing.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    37
import javax.accessibility.*;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    38
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    39
/**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    40
 * <p>The {@code Translator} class provides a translation to interface
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    41
 * {@link javax.accessibility.Accessible Accessible}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    42
 * for objects that do not implement interface {@code Accessible}.  Assistive
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    43
 * technologies can use the {@link #getAccessible getAccessible} class method of
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    44
 * {@code Translator} to obtain an object that implements interface {@code Accessible}.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    45
 * If the object passed in already implements interface {@code Accessible},
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    46
 * {@code getAccessible} merely returns the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    47
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    48
 * <p>An example of how an assistive technology might use the {@code Translator}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    49
 * class is as follows:
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    50
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    51
 * <PRE>
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    52
 *    Accessible accessible = Translator.getAccessible(someObj);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    53
 *    // obtain information from the 'accessible' object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    54
 * </PRE>
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    55
 *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    56
 * <P>Note:  This implementation is missing many things and is not a recommended way
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    57
 * to implement accessibility features for a toolkit.  Instead of relying upon this
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    58
 * code, a toolkit's components should implement interface {@code Accessible} directly.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    59
 */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    60
public class Translator extends AccessibleContext
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    61
        implements Accessible, AccessibleComponent {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    62
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    63
    /** The source object needing translating. */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    64
    protected Object source;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    65
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    66
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    67
     * Find a translator for this class.  If one doesn't exist for this
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    68
     * class explicitly, try its superclass and so on.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    69
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    70
     * @param c a Class
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    71
     * @return the {@code Translator} Class for the Class passed in
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    72
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    73
    protected static Class<?> getTranslatorClass(Class<?> c) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    74
        Class<?> t = null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    75
        if (c == null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    76
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    77
        }
37571
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    78
        switch (c.getSimpleName()) {
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    79
            case "Button":
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    80
                t = ButtonTranslator.class;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    81
                break;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    82
            case "Checkbox":
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    83
                t = CheckboxTranslator.class;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    84
                break;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    85
            case "Label":
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    86
                t = LabelTranslator.class;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    87
                break;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    88
            case "List":
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    89
                t = ListTranslator.class;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    90
                break;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    91
            case "TextComponent":
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    92
                t = TextComponentTranslator.class;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    93
                break;
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    94
        }
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    95
        if (t != null) {
29883
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    96
            return t;
37571
f26a25afa773 8150056: Remove package access restriction of com.sun.java.accessibility.util.internal
ptbrunet
parents: 36452
diff changeset
    97
        } else {
29883
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    98
            return getTranslatorClass(c.getSuperclass());
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
    99
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   100
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   101
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   102
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   103
     * Obtain an object that implements interface {@code Accessible}.  If the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   104
     * passed in already implements interface {@code Accessible}, {@code getAccessible}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   105
     * merely returns the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   106
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   107
     * @param o an Object; if a null is passed in a null is returned
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   108
     * @return an {@code Object}, possibly the {@code Object} passed in, that
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   109
     *     implements the {@code Accessible} interface for the {@code Object}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   110
     *     which was passed in
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   111
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   112
    public static Accessible getAccessible(Object o) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   113
        Accessible a = null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   114
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   115
        if (o == null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   116
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   117
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   118
        if (o instanceof Accessible) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   119
            a = (Accessible)o;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   120
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   121
            Class<?> translatorClass = getTranslatorClass(o.getClass());
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   122
            if (translatorClass != null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   123
                try {
37782
ad8fe7507ecc 6850612: Deprecate Class.newInstance since it violates the checked exception language contract
darcy
parents: 37571
diff changeset
   124
                    @SuppressWarnings("deprecation")
29883
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   125
                    Translator t = (Translator)translatorClass.newInstance();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   126
                    t.setSource(o);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   127
                    a = t;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   128
                } catch (Exception e) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   129
                }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   130
            }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   131
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   132
        if (a == null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   133
            a = new Translator(o);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   134
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   135
        return a;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   136
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   137
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   138
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   139
     * Create a new {@code Translator}.  You must call the {@link #setSource setSource}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   140
     * method to set the object to be translated after calling this constructor.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   141
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   142
    public Translator() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   143
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   144
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   145
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   146
     * Create a new {@code Translator} with the source object o.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   147
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   148
     * @param o the Component that does not implement interface
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   149
     *     {@link javax.accessibility.Accessible Accessible}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   150
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   151
    public Translator(Object o) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   152
        source = o;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   153
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   154
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   155
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   156
     * Get the source {@code Object} of the {@code Translator}.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   157
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   158
     * @return the source {@code Object} of the {@code Translator}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   159
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   160
    public Object getSource() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   161
        return source;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   162
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   163
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   164
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   165
     * Set the source object of the {@code Translator}.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   166
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   167
     * @param o the Component that does not implement interface Accessible
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   168
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   169
    public void setSource(Object o) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   170
        source = o;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   171
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   172
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   173
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   174
     * Returns true if this object is the same as the one passed in.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   175
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   176
     * @param o the {@code Object} to check against
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   177
     * @return true if this is the same object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   178
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   179
    public boolean equals(Object o) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   180
        if (o instanceof Translator) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   181
            return java.util.Objects.equals(source, o);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   182
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   183
            return false;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   184
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   185
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   186
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   187
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   188
     * Return hashcode.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   189
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   190
     * @return hashcode
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   191
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   192
    public int hashCode() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   193
        return java.util.Objects.hashCode(source);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   194
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   195
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   196
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   197
// Accessible methods
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   198
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   199
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   200
     * Returns this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   201
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   202
    public AccessibleContext getAccessibleContext() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   203
        return this;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   204
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   205
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   206
// AccessibleContext methods
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   207
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   208
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   209
     * Get the accessible name of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   210
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   211
     * @return the localized name of the object; can be null if this object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   212
     *     does not have a name
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   213
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   214
    public String getAccessibleName() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   215
        if (source instanceof MenuItem) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   216
            return ((MenuItem) source).getLabel();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   217
        } else if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   218
            return ((Component) source).getName();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   219
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   220
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   221
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   222
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   223
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   224
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   225
     * Set the name of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   226
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   227
    public void setAccessibleName(String s) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   228
        if (source instanceof MenuItem) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   229
            ((MenuItem) source).setLabel(s);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   230
        } else if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   231
            ((Component) source).setName(s);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   232
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   233
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   234
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   235
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   236
     * Get the accessible description of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   237
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   238
     * @return the description of the object; can be null if this object does
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   239
     * not have a description
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   240
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   241
    public String getAccessibleDescription() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   242
        return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   243
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   244
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   245
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   246
     * Set the accessible description of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   247
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   248
     * @param s the new localized description of the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   249
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   250
    public void setAccessibleDescription(String s) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   251
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   252
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   253
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   254
     * Get the role of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   255
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   256
     * @return an instance of AccessibleRole describing the role of the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   257
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   258
    public AccessibleRole getAccessibleRole() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   259
        return AccessibleRole.UNKNOWN;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   260
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   261
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   262
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   263
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   264
     * Get the state of this object, given an already populated state.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   265
     * This method is intended for use by subclasses so they don't have
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   266
     * to check for everything.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   267
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   268
     * @return an instance of {@code AccessibleStateSet}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   269
     *     containing the current state of the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   270
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   271
    public AccessibleStateSet getAccessibleStateSet() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   272
        AccessibleStateSet states = new AccessibleStateSet();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   273
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   274
            Component c = (Component) source;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   275
            for (Container p = c.getParent(); p != null; p = p.getParent()) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   276
                if (p instanceof Window) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   277
                    if (((Window)p).getFocusOwner() == c) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   278
                        states.add(AccessibleState.FOCUSED);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   279
                    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   280
                }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   281
            }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   282
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   283
        if (isEnabled()) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   284
            states.add(AccessibleState.ENABLED);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   285
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   286
        if (isFocusTraversable()) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   287
            states.add(AccessibleState.FOCUSABLE);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   288
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   289
        if (source instanceof MenuItem) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   290
            states.add(AccessibleState.FOCUSABLE);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   291
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   292
        return states;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   293
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   294
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   295
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   296
     * Get the accessible parent of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   297
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   298
     * @return the accessible parent of this object; can be null if this
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   299
     *     object does not have an accessible parent
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   300
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   301
    public Accessible getAccessibleParent() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   302
        if (accessibleParent != null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   303
            return accessibleParent;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   304
        } else if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   305
            return getAccessible(((Component) source).getParent());
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   306
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   307
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   308
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   309
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   310
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   311
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   312
     * Get the index of this object in its accessible parent.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   313
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   314
     * @return -1 of this object does not have an accessible parent; otherwise,
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   315
     * the index of the child in its accessible parent
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   316
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   317
    public int getAccessibleIndexInParent() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   318
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   319
            Container parent = ((Component) source).getParent();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   320
            if (parent != null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   321
                Component ca[] = parent.getComponents();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   322
                for (int i = 0; i < ca.length; i++) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   323
                    if (source.equals(ca[i])) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   324
                        return i;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   325
                    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   326
                }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   327
            }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   328
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   329
        return -1;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   330
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   331
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   332
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   333
     * Returns the number of accessible children in the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   334
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   335
     * @return the number of accessible children in the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   336
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   337
    public int getAccessibleChildrenCount() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   338
        if (source instanceof Container) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   339
            Component[] children = ((Container) source).getComponents();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   340
            int count = 0;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   341
            for (int i = 0; i < children.length; i++) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   342
                Accessible a = getAccessible(children[i]);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   343
                if (a != null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   344
                    count++;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   345
                }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   346
            }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   347
            return count;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   348
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   349
            return 0;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   350
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   351
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   352
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   353
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   354
     * Return the nth accessible child of the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   355
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   356
     * @param i zero-based index of child
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   357
     * @return the nth accessible child of the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   358
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   359
    public Accessible getAccessibleChild(int i) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   360
        if (source instanceof Container) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   361
            Component[] children = ((Container) source).getComponents();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   362
            int count = 0;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   363
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   364
            for (int j = 0; j < children.length; j++) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   365
                Accessible a = getAccessible(children[j]);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   366
                if (a != null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   367
                    if (count == i) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   368
                        AccessibleContext ac = a.getAccessibleContext();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   369
                        if (ac != null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   370
                            ac.setAccessibleParent(this);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   371
                        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   372
                        return a;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   373
                    } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   374
                        count++;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   375
                    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   376
                }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   377
            }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   378
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   379
        return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   380
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   381
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   382
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   383
     * Gets the {@code Locale} of the component. If the component does not have a
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   384
     * locale, the locale of its parent is returned.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   385
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   386
     * @return the {@code Locale} of the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   387
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   388
    public Locale getLocale() throws IllegalComponentStateException {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   389
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   390
            return ((Component) source).getLocale();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   391
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   392
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   393
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   394
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   395
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   396
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   397
     * Add a {@code PropertyChangeListener} to the listener list.  The listener
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   398
     * is registered for all properties.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   399
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   400
    public void addPropertyChangeListener(PropertyChangeListener l) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   401
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   402
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   403
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   404
     * Remove the {@code PropertyChangeListener} from the listener list.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   405
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   406
    public void removePropertyChangeListener(PropertyChangeListener l) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   407
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   408
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   409
// AccessibleComponent methods
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   410
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   411
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   412
     * Get the background {@code Color} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   413
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   414
     * @return if supported, the background {@code Color} of the object;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   415
     *     otherwise, null
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   416
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   417
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   418
    public Color getBackground() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   419
        if (source instanceof Component) { // MenuComponent doesn't do background
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   420
            return ((Component) source).getBackground();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   421
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   422
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   423
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   424
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   425
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   426
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   427
     * Set the background {@code Color} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   428
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   429
     * @param c the new {@code Color} for the background
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   430
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   431
    public void setBackground(Color c) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   432
        if (source instanceof Component) { // MenuComponent doesn't do background
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   433
            ((Component) source).setBackground(c);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   434
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   435
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   436
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   437
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   438
     * Get the foreground {@code Color} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   439
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   440
     * @return if supported, the foreground {@code Color} of the object; otherwise, null
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   441
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   442
    public Color getForeground() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   443
        if (source instanceof Component) { // MenuComponent doesn't do foreground
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   444
            return ((Component) source).getForeground();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   445
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   446
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   447
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   448
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   449
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   450
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   451
     * Set the foreground {@code Color} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   452
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   453
     * @param c the new {@code Color} for the foreground
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   454
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   455
    public void setForeground(Color c) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   456
        if (source instanceof Component) { // MenuComponent doesn't do foreground
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   457
            ((Component) source).setForeground(c);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   458
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   459
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   460
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   461
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   462
     * Get the {@code Cursor} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   463
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   464
     * @return if supported, the Cursor of the object; otherwise, null
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   465
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   466
    public Cursor getCursor() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   467
        if (source instanceof Component) { // MenuComponent doesn't do cursor
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   468
            return ((Component) source).getCursor();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   469
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   470
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   471
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   472
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   473
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   474
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   475
     * Set the {@code Cursor} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   476
     * @param c the new {@code Cursor} for the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   477
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   478
    public void setCursor(Cursor c) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   479
        if (source instanceof Component) { // MenuComponent doesn't do cursor
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   480
            ((Component) source).setCursor(c);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   481
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   482
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   483
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   484
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   485
     * Get the {@code Font} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   486
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   487
     * @return if supported, the {@code Font} for the object; otherwise, null
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   488
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   489
    public Font getFont() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   490
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   491
            return ((Component) source).getFont();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   492
        } else if (source instanceof MenuComponent) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   493
            return ((MenuComponent) source).getFont();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   494
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   495
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   496
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   497
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   498
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   499
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   500
     * Set the {@code Font} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   501
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   502
     * @param f the new {@code Font} for the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   503
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   504
    public void setFont(Font f) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   505
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   506
            ((Component) source).setFont(f);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   507
        } else if (source instanceof MenuComponent) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   508
            ((MenuComponent) source).setFont(f);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   509
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   510
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   511
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   512
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   513
     * Get the {@code FontMetrics} of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   514
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   515
     * @param f the {@code Font}
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   516
     * @return if supported, the {@code FontMetrics} the object; otherwise, null
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   517
     * @see #getFont
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   518
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   519
    public FontMetrics getFontMetrics(Font f) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   520
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   521
            return ((Component) source).getFontMetrics(f);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   522
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   523
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   524
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   525
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   526
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   527
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   528
     * Determine if the object is enabled.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   529
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   530
     * @return true if object is enabled; otherwise, false
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   531
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   532
    public boolean isEnabled() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   533
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   534
            return ((Component) source).isEnabled();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   535
        } else if (source instanceof MenuItem) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   536
            return ((MenuItem) source).isEnabled();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   537
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   538
            return true;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   539
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   540
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   541
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   542
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   543
     * Set the enabled state of the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   544
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   545
     * @param b if true, enables this object; otherwise, disables it
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   546
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   547
    public void setEnabled(boolean b) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   548
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   549
            ((Component) source).setEnabled(b);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   550
        } else if (source instanceof MenuItem) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   551
            ((MenuItem) source).setEnabled(b);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   552
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   553
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   554
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   555
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   556
     * Determine if the object is visible.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   557
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   558
     * @return true if object is visible; otherwise, false
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   559
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   560
    public boolean isVisible() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   561
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   562
            return ((Component) source).isVisible();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   563
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   564
            return false;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   565
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   566
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   567
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   568
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   569
     * Set the visible state of the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   570
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   571
     * @param b if true, shows this object; otherwise, hides it
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   572
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   573
    public void setVisible(boolean b) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   574
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   575
            ((Component) source).setVisible(b);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   576
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   577
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   578
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   579
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   580
     * Determine if the object is showing.  This is determined by checking
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   581
     * the visibility of the object and ancestors of the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   582
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   583
     * @return true if object is showing; otherwise, false
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   584
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   585
    public boolean isShowing() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   586
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   587
            return ((Component) source).isShowing();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   588
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   589
            return false;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   590
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   591
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   592
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   593
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   594
     * Checks whether the specified {@code Point} is within this
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   595
     * object's bounds, where the {@code Point} is relative to the coordinate
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   596
     * system of the object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   597
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   598
     * @param p the {@code Point} relative to the coordinate system of the object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   599
     * @return true if object contains {@code Point}; otherwise false
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   600
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   601
    public boolean contains(Point p) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   602
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   603
            return ((Component) source).contains(p);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   604
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   605
            return false;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   606
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   607
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   608
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   609
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   610
     * Returns the location of the object on the screen.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   611
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   612
     * @return location of object on screen; can be null if this object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   613
     *     is not on the screen
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   614
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   615
    public Point getLocationOnScreen() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   616
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   617
            return ((Component) source).getLocationOnScreen();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   618
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   619
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   620
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   621
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   622
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   623
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   624
     * Returns the location of the object relative to parent.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   625
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   626
     * @return location of object relative to parent; can be null if
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   627
     *     this object or its parent are not on the screen
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   628
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   629
    public Point getLocation() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   630
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   631
            return ((Component) source).getLocation();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   632
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   633
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   634
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   635
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   636
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   637
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   638
     * Sets the location of the object relative to parent.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   639
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   640
    public void setLocation(Point p) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   641
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   642
            ((Component) source).setLocation(p);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   643
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   644
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   645
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   646
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   647
     * Returns the current bounds of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   648
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   649
     * @return current bounds of object; can be null if this object
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   650
     *     is not on the screen
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   651
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   652
    public Rectangle getBounds() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   653
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   654
            return ((Component) source).getBounds();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   655
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   656
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   657
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   658
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   659
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   660
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   661
     * Sets the current bounds of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   662
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   663
    public void setBounds(Rectangle r) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   664
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   665
            ((Component) source).setBounds(r);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   666
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   667
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   668
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   669
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   670
     * Returns the current size of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   671
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   672
     * @return current size of object; can be null if this object is
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   673
     *     not on the screen
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   674
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   675
    public Dimension getSize() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   676
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   677
            return ((Component) source).getSize();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   678
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   679
            return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   680
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   681
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   682
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   683
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   684
     * Sets the current size of this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   685
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   686
    public void setSize(Dimension d) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   687
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   688
            ((Component) source).setSize(d);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   689
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   690
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   691
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   692
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   693
     * Returns the accessible child contained at the local coordinate
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   694
     * Point, if one exists.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   695
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   696
     * @return the Accessible at the specified location, if it exists
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   697
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   698
    public Accessible getAccessibleAt(Point p) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   699
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   700
            Component c = ((Component) source).getComponentAt(p);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   701
            if (c != null) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   702
                return (getAccessible(c));
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   703
            }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   704
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   705
        return null;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   706
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   707
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   708
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   709
     * Returns whether this object can accept focus or not.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   710
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   711
     * @return true if object can accept focus; otherwise false
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   712
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   713
    @SuppressWarnings("deprecation")
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   714
    public boolean isFocusTraversable() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   715
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   716
            return ((Component) source).isFocusTraversable();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   717
        } else {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   718
            return false;
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   719
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   720
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   721
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   722
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   723
     * Requests focus for this object.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   724
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   725
    public void requestFocus() {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   726
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   727
            ((Component) source).requestFocus();
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   728
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   729
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   730
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   731
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   732
     * Adds the specified {@code FocusListener} to receive focus events from
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   733
     * this component.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   734
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   735
     * @param l the focus listener
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   736
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   737
    public synchronized void addFocusListener(FocusListener l) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   738
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   739
            ((Component) source).addFocusListener(l);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   740
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   741
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   742
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   743
    /**
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   744
     * Removes the specified focus listener so it no longer receives focus
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   745
     * events from this component.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   746
     *
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   747
     * @param l the focus listener; this method performs no function, nor does it
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   748
     *     throw an exception if the listener specified was not previously added
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   749
     *     to this component; if listener is null, no exception is thrown and no
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   750
     *     action is performed.
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   751
     */
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   752
    public synchronized void removeFocusListener(FocusListener l) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   753
        if (source instanceof Component) {
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   754
            ((Component) source).removeFocusListener(l);
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   755
        }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   756
    }
e02d168adbc6 8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff changeset
   757
}