Showing the changes to java/pkg/java/awt/Panel.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,133 @@ | ||
| 1 | +/* | |
| 2 | + * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved. | |
| 3 | + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
| 4 | + * | |
| 5 | + * This code is free software; you can redistribute it and/or modify it | |
| 6 | + * under the terms of the GNU General Public License version 2 only, as | |
| 7 | + * published by the Free Software Foundation. Oracle designates this | |
| 8 | + * particular file as subject to the "Classpath" exception as provided | |
| 9 | + * by Oracle in the LICENSE file that accompanied this code. | |
| 10 | + * | |
| 11 | + * This code is distributed in the hope that it will be useful, but WITHOUT | |
| 12 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 13 | + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 14 | + * version 2 for more details (a copy is included in the LICENSE file that | |
| 15 | + * accompanied this code). | |
| 16 | + * | |
| 17 | + * You should have received a copy of the GNU General Public License version | |
| 18 | + * 2 along with this work; if not, write to the Free Software Foundation, | |
| 19 | + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 20 | + * | |
| 21 | + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
| 22 | + * or visit www.oracle.com if you need additional information or have any | |
| 23 | + * questions. | |
| 24 | + */ | |
| 25 | +package java.awt; | |
| 26 | + | |
| 27 | +import javax.accessibility.*; | |
| 28 | + | |
| 29 | +/** | |
| 30 | + * <code>Panel</code> is the simplest container class. A panel | |
| 31 | + * provides space in which an application can attach any other | |
| 32 | + * component, including other panels. | |
| 33 | + * <p> | |
| 34 | + * The default layout manager for a panel is the | |
| 35 | + * <code>FlowLayout</code> layout manager. | |
| 36 | + * | |
| 37 | + * @author Sami Shaio | |
| 38 | + * @see java.awt.FlowLayout | |
| 39 | + * @since JDK1.0 | |
| 40 | + */ | |
| 41 | +public class Panel extends Container implements Accessible { | |
| 42 | + private static final String base = "panel"; | |
| 43 | + private static int nameCounter = 0; | |
| 44 | + | |
| 45 | + /* | |
| 46 | + * JDK 1.1 serialVersionUID | |
| 47 | + */ | |
| 48 | + private static final long serialVersionUID = -2728009084054400034L; | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * Creates a new panel using the default layout manager. | |
| 52 | + * The default layout manager for all panels is the | |
| 53 | + * <code>FlowLayout</code> class. | |
| 54 | + */ | |
| 55 | + public Panel() { | |
| 56 | + this(new FlowLayout()); | |
| 57 | + } | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * Creates a new panel with the specified layout manager. | |
| 61 | + * @param layout the layout manager for this panel. | |
| 62 | + * @since JDK1.1 | |
| 63 | + */ | |
| 64 | + public Panel(LayoutManager layout) { | |
| 65 | + setLayout(layout); | |
| 66 | + } | |
| 67 | + | |
| 68 | + /** | |
| 69 | + * Construct a name for this component. Called by getName() when the | |
| 70 | + * name is null. | |
| 71 | + */ | |
| 72 | + String constructComponentName() { | |
| 73 | + synchronized (Panel.class) { | |
| 74 | + return base + nameCounter++; | |
| 75 | + } | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Creates the Panel's peer. The peer allows you to modify the | |
| 80 | + * appearance of the panel without changing its functionality. | |
| 81 | + */ | |
| 82 | + | |
| 83 | + public void addNotify() { | |
| 84 | + synchronized (getTreeLock()) { | |
| 85 | + if (peer == null) | |
| 86 | + peer = getToolkit().createPanel(this); | |
| 87 | + super.addNotify(); | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | +///////////////// | |
| 92 | +// Accessibility support | |
| 93 | +//////////////// | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * Gets the AccessibleContext associated with this Panel. | |
| 97 | + * For panels, the AccessibleContext takes the form of an | |
| 98 | + * AccessibleAWTPanel. | |
| 99 | + * A new AccessibleAWTPanel instance is created if necessary. | |
| 100 | + * | |
| 101 | + * @return an AccessibleAWTPanel that serves as the | |
| 102 | + * AccessibleContext of this Panel | |
| 103 | + * @since 1.3 | |
| 104 | + */ | |
| 105 | + public AccessibleContext getAccessibleContext() { | |
| 106 | + if (accessibleContext == null) { | |
| 107 | + accessibleContext = new AccessibleAWTPanel(); | |
| 108 | + } | |
| 109 | + return accessibleContext; | |
| 110 | + } | |
| 111 | + | |
| 112 | + /** | |
| 113 | + * This class implements accessibility support for the | |
| 114 | + * <code>Panel</code> class. It provides an implementation of the | |
| 115 | + * Java Accessibility API appropriate to panel user-interface elements. | |
| 116 | + * @since 1.3 | |
| 117 | + */ | |
| 118 | + protected class AccessibleAWTPanel extends AccessibleAWTContainer { | |
| 119 | + | |
| 120 | + private static final long serialVersionUID = -6409552226660031050L; | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * Get the role of this object. | |
| 124 | + * | |
| 125 | + * @return an instance of AccessibleRole describing the role of the | |
| 126 | + * object | |
| 127 | + */ | |
| 128 | + public AccessibleRole getAccessibleRole() { | |
| 129 | + return AccessibleRole.PANEL; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + | |
| 133 | +} | |