jdk/src/share/classes/java/awt/Panel.java
author malenkov
Wed, 07 May 2008 23:20:32 +0400
changeset 466 6acd5ec503a8
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE Summary: Add the Transient annotation and support it (JSR-273) Reviewed-by: peterz, loneid
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 1995-2007 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
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * <code>Panel</code> is the simplest container class. A panel
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * provides space in which an application can attach any other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * component, including other panels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * The default layout manager for a panel is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <code>FlowLayout</code> layout manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * @see     java.awt.FlowLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
public class Panel extends Container implements Accessible {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    private static final String base = "panel";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
     private static final long serialVersionUID = -2728009084054400034L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
     * Creates a new panel using the default layout manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * The default layout manager for all panels is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * <code>FlowLayout</code> class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public Panel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        this(new FlowLayout());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * Creates a new panel with the specified layout manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * @param layout the layout manager for this panel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * @since JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    public Panel(LayoutManager layout) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        setLayout(layout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * Construct a name for this component.  Called by getName() when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * name is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        synchronized (Panel.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * Creates the Panel's peer.  The peer allows you to modify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * appearance of the panel without changing its functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            if (peer == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                peer = getToolkit().createPanel(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Gets the AccessibleContext associated with this Panel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * For panels, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * AccessibleAWTPanel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * A new AccessibleAWTPanel instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @return an AccessibleAWTPanel that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     *         AccessibleContext of this Panel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            accessibleContext = new AccessibleAWTPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * <code>Panel</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Java Accessibility API appropriate to panel user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected class AccessibleAWTPanel extends AccessibleAWTContainer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        private static final long serialVersionUID = -6409552226660031050L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            return AccessibleRole.PANEL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
}