001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: /**
018: * @author Dmitry A. Durnev
019: * @version $Revision$
020: */package java.awt;
021:
022: import javax.accessibility.Accessible;
023: import javax.accessibility.AccessibleContext;
024: import javax.accessibility.AccessibleRole;
025:
026: public class Panel extends Container implements Accessible {
027:
028: private static final long serialVersionUID = -2728009084054400034L;
029:
030: protected class AccessibleAWTPanel extends AccessibleAWTContainer {
031:
032: private static final long serialVersionUID = -6409552226660031050L;
033:
034: @Override
035: public AccessibleRole getAccessibleRole() {
036: toolkit.lockAWT();
037: try {
038: return AccessibleRole.PANEL;
039: } finally {
040: toolkit.unlockAWT();
041: }
042: }
043:
044: }
045:
046: public Panel() {
047: this (new FlowLayout());
048: toolkit.lockAWT();
049: try {
050: } finally {
051: toolkit.unlockAWT();
052: }
053: }
054:
055: public Panel(LayoutManager layout) {
056: toolkit.lockAWT();
057: try {
058: super .setLayout(layout);
059: } finally {
060: toolkit.unlockAWT();
061: }
062: }
063:
064: @Override
065: public void addNotify() {
066: toolkit.lockAWT();
067: try {
068: super .addNotify();
069: } finally {
070: toolkit.unlockAWT();
071: }
072: }
073:
074: @Override
075: public AccessibleContext getAccessibleContext() {
076: toolkit.lockAWT();
077: try {
078: return super .getAccessibleContext();
079: } finally {
080: toolkit.unlockAWT();
081: }
082: }
083:
084: @Override
085: AccessibleContext createAccessibleContext() {
086: return new AccessibleAWTPanel();
087: }
088:
089: @Override
090: ComponentBehavior createBehavior() {
091: return GraphicsEnvironment.getLocalGraphicsEnvironment()
092: .isHeadlessInstance() ? new LWBehavior(this )
093: : new HWBehavior(this );
094: }
095:
096: @Override
097: String autoName() {
098: return ("panel" + toolkit.autoNumber.nextPanel++); //$NON-NLS-1$
099: }
100: }
|