jdk/src/share/classes/javax/swing/ClientPropertyKey.java
author peterz
Fri, 25 Dec 2009 17:47:08 +0300
changeset 4842 c9f791782a29
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6860438: [Nimbus] Code to globally set slider's thumb background doesn't work as specified Reviewed-by: rupashka
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2006 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * An enumeration for keys used as client properties within the Swing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * This enum holds only a small subset of the keys currently used within Swing,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * but we may move more of them here in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * Adding an item to, and using, this class instead of {@code String} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * client properties protects against conflicts with developer-set client
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * properties. Using this class also avoids a problem with {@code StringBuilder}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * and {@code StringBuffer} keys, whereby the keys are not recognized upon
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * deserialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * When a client property value associated with one of these keys does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * implement {@code Serializable}, the result during serialization depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * on how the key is defined here. Historically, client properties with values
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * not implementing {@code Serializable} have simply been dropped and left out
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * of the serialized representation. To define keys with such behavior in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * enum, provide a value of {@code false} for the {@code reportValueNotSerializable}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * property. When migrating existing properties to this enum, one may wish to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * consider using this by default, to preserve backward compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * To instead have a {@code NotSerializableException} thrown when a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * {@code non-Serializable} property is encountered, provide the value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * {@code true} for the {@code reportValueNotSerializable} property. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * is useful when the property represents something that the developer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * needs to know about when it cannot be serialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @author  Shannon Hickey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
enum ClientPropertyKey {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Key used by JComponent for storing InputVerifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    JComponent_INPUT_VERIFIER(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * Key used by JComponent for storing TransferHandler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    JComponent_TRANSFER_HANDLER(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Key used by JComponent for storing AncestorNotifier.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    JComponent_ANCESTOR_NOTIFIER(true),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Key used by PopupFactory to force heavy weight popups for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    PopupFactory_FORCE_HEAVYWEIGHT_POPUP(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * Whether or not a {@code NotSerializableException} should be thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * during serialization, when the value associated with this key does
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * not implement {@code Serializable}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    private final boolean reportValueNotSerializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * Constructs a key with the {@code reportValueNotSerializable} property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * set to {@code false}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private ClientPropertyKey() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        this(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Constructs a key with the {@code reportValueNotSerializable} property
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * set to the given value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private ClientPropertyKey(boolean reportValueNotSerializable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this.reportValueNotSerializable = reportValueNotSerializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * Returns whether or not a {@code NotSerializableException} should be thrown
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * during serialization, when the value associated with this key does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * not implement {@code Serializable}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public boolean getReportValueNotSerializable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return reportValueNotSerializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
}