Source Code Cross Referenced for JComponent.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » javax package » javax.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
0003:         *  contributor license agreements.  See the NOTICE file distributed with
0004:         *  this work for additional information regarding copyright ownership.
0005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
0006:         *  (the "License"); you may not use this file except in compliance with
0007:         *  the License.  You may obtain a copy of the License at
0008:         *
0009:         *     http://www.apache.org/licenses/LICENSE-2.0
0010:         *
0011:         *  Unless required by applicable law or agreed to in writing, software
0012:         *  distributed under the License is distributed on an "AS IS" BASIS,
0013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014:         *  See the License for the specific language governing permissions and
0015:         *  limitations under the License.
0016:         */
0017:
0018:        package javax.swing;
0019:
0020:        import java.applet.Applet;
0021:        import java.awt.AWTEvent;
0022:        import java.awt.Component;
0023:        import java.awt.Container;
0024:        import java.awt.Dimension;
0025:        import java.awt.FocusTraversalPolicy;
0026:        import java.awt.Graphics;
0027:        import java.awt.Graphics2D;
0028:        import java.awt.Image;
0029:        import java.awt.Insets;
0030:        import java.awt.KeyEventPostProcessor;
0031:        import java.awt.KeyboardFocusManager;
0032:        import java.awt.LayoutManager;
0033:        import java.awt.LayoutManager2;
0034:        import java.awt.Point;
0035:        import java.awt.Rectangle;
0036:        import java.awt.Shape;
0037:        import java.awt.Window;
0038:        import java.awt.dnd.DropTarget;
0039:        import java.awt.event.ActionListener;
0040:        import java.awt.event.ComponentEvent;
0041:        import java.awt.event.ComponentListener;
0042:        import java.awt.event.ContainerEvent;
0043:        import java.awt.event.ContainerListener;
0044:        import java.awt.event.FocusEvent;
0045:        import java.awt.event.FocusListener;
0046:        import java.awt.event.HierarchyBoundsAdapter;
0047:        import java.awt.event.HierarchyEvent;
0048:        import java.awt.event.HierarchyListener;
0049:        import java.awt.event.KeyEvent;
0050:        import java.awt.event.MouseEvent;
0051:        import java.beans.BeanInfo;
0052:        import java.beans.IntrospectionException;
0053:        import java.beans.Introspector;
0054:        import java.beans.PropertyChangeListener;
0055:        import java.beans.PropertyDescriptor;
0056:        import java.beans.PropertyVetoException;
0057:        import java.beans.VetoableChangeListener;
0058:        import java.beans.VetoableChangeSupport;
0059:        import java.io.Serializable;
0060:        import java.lang.reflect.InvocationTargetException;
0061:        import java.util.ArrayList;
0062:        import java.util.Arrays;
0063:        import java.util.EventListener;
0064:        import java.util.HashMap;
0065:        import java.util.HashSet;
0066:        import java.util.Locale;
0067:        import java.util.Set;
0068:        import javax.accessibility.Accessible;
0069:        import javax.accessibility.AccessibleContext;
0070:        import javax.accessibility.AccessibleExtendedComponent;
0071:        import javax.accessibility.AccessibleKeyBinding;
0072:        import javax.accessibility.AccessibleRole;
0073:        import javax.accessibility.AccessibleState;
0074:        import javax.accessibility.AccessibleStateSet;
0075:        import javax.swing.border.AbstractBorder;
0076:        import javax.swing.border.Border;
0077:        import javax.swing.border.CompoundBorder;
0078:        import javax.swing.border.TitledBorder;
0079:        import javax.swing.event.AncestorEvent;
0080:        import javax.swing.event.AncestorListener;
0081:        import javax.swing.event.EventListenerList;
0082:        import javax.swing.plaf.ComponentUI;
0083:        import org.apache.harmony.awt.ClipRegion;
0084:        import org.apache.harmony.awt.gl.MultiRectArea;
0085:        import org.apache.harmony.x.swing.internal.nls.Messages;
0086:        import org.apache.harmony.x.swing.StringConstants;
0087:        import org.apache.harmony.x.swing.Utilities;
0088:
0089:        public abstract class JComponent extends Container implements 
0090:                Serializable {
0091:            private class AncestorComponentNotifier extends
0092:                    HierarchyBoundsAdapter implements  HierarchyListener,
0093:                    ComponentListener {
0094:                public void componentMoved(ComponentEvent e) {
0095:                    final Container ancestor = (Container) e.getComponent();
0096:                    fireAncestorEvent(AncestorEvent.ANCESTOR_MOVED, ancestor,
0097:                            ancestor.getParent());
0098:                }
0099:
0100:                @Override
0101:                public void ancestorMoved(HierarchyEvent e) {
0102:                    if (!isVisible()) {
0103:                        return;
0104:                    }
0105:                    final Container ancestor = (Container) e.getChanged();
0106:                    fireAncestorEvent(AncestorEvent.ANCESTOR_MOVED, ancestor,
0107:                            ancestor.getParent());
0108:                }
0109:
0110:                public void hierarchyChanged(HierarchyEvent e) {
0111:                    if (((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0)
0112:                            || ((e.getChangeFlags() & HierarchyEvent.HIERARCHY_CHANGED) != 0)) {
0113:                        fireAncestorEvent(
0114:                                isShowing() ? AncestorEvent.ANCESTOR_ADDED
0115:                                        : AncestorEvent.ANCESTOR_REMOVED,
0116:                                (Container) e.getChanged(), e
0117:                                        .getChangedParent());
0118:                    }
0119:                }
0120:
0121:                public void componentResized(ComponentEvent e) {
0122:                }
0123:
0124:                public void componentShown(ComponentEvent e) {
0125:                }
0126:
0127:                public void componentHidden(ComponentEvent e) {
0128:                }
0129:
0130:                private void fireAncestorEvent(int eventID, Container ancestor,
0131:                        Container ancestorParent) {
0132:                    final AncestorListener[] listeners = getAncestorListeners();
0133:                    AncestorEvent ancestorEvent = new AncestorEvent(
0134:                            JComponent.this , eventID, ancestor, ancestorParent);
0135:                    for (int i = 0; i < listeners.length; i++) {
0136:                        if (eventID == AncestorEvent.ANCESTOR_ADDED) {
0137:                            listeners[i].ancestorAdded(ancestorEvent);
0138:                        } else if (eventID == AncestorEvent.ANCESTOR_REMOVED) {
0139:                            listeners[i].ancestorRemoved(ancestorEvent);
0140:                        } else if (eventID == AncestorEvent.ANCESTOR_MOVED) {
0141:                            listeners[i].ancestorMoved(ancestorEvent);
0142:                        }
0143:                    }
0144:                }
0145:            };
0146:
0147:            public abstract class AccessibleJComponent extends
0148:                    Container.AccessibleAWTContainer implements 
0149:                    AccessibleExtendedComponent {
0150:                protected class AccessibleContainerHandler implements 
0151:                        ContainerListener {
0152:                    public void componentAdded(ContainerEvent event) {
0153:                        firePropertyChange(ACCESSIBLE_CHILD_PROPERTY, null,
0154:                                event.getChild().getAccessibleContext());
0155:                    }
0156:
0157:                    public void componentRemoved(ContainerEvent event) {
0158:                        firePropertyChange(ACCESSIBLE_CHILD_PROPERTY, event
0159:                                .getChild().getAccessibleContext(), null);
0160:                    }
0161:                }
0162:
0163:                protected class AccessibleFocusHandler implements  FocusListener {
0164:                    public void focusGained(FocusEvent event) {
0165:                        firePropertyChange(ACCESSIBLE_STATE_PROPERTY, null,
0166:                                AccessibleState.FOCUSED);
0167:                    }
0168:
0169:                    public void focusLost(FocusEvent event) {
0170:                        firePropertyChange(ACCESSIBLE_STATE_PROPERTY,
0171:                                AccessibleState.FOCUSED, null);
0172:                    }
0173:                }
0174:
0175:                protected ContainerListener accessibleContainerHandler;
0176:
0177:                protected FocusListener accessibleFocusHandler;
0178:
0179:                protected AccessibleJComponent() {
0180:                }
0181:
0182:                protected String getBorderTitle(Border border) {
0183:                    if (border instanceof  TitledBorder) {
0184:                        return ((TitledBorder) border).getTitle();
0185:                    } else if (border instanceof  CompoundBorder) {
0186:                        CompoundBorder compoundBorder = (CompoundBorder) border;
0187:                        String title = getBorderTitle(compoundBorder
0188:                                .getInsideBorder());
0189:                        return (title != null) ? title
0190:                                : getBorderTitle(compoundBorder
0191:                                        .getOutsideBorder());
0192:                    }
0193:                    return null;
0194:                }
0195:
0196:                @Override
0197:                public AccessibleStateSet getAccessibleStateSet() {
0198:                    AccessibleStateSet stateSet = super .getAccessibleStateSet();
0199:                    if (isShowing()) {
0200:                        stateSet.add(AccessibleState.SHOWING);
0201:                    }
0202:                    return stateSet;
0203:                }
0204:
0205:                @Override
0206:                public AccessibleRole getAccessibleRole() {
0207:                    return AccessibleRole.SWING_COMPONENT;
0208:                }
0209:
0210:                public AccessibleKeyBinding getAccessibleKeyBinding() {
0211:                    return null;
0212:                }
0213:
0214:                @Override
0215:                public Accessible getAccessibleChild(int childIndex) {
0216:                    return super .getAccessibleChild(childIndex);
0217:                }
0218:
0219:                public String getToolTipText() {
0220:                    return null;
0221:                }
0222:
0223:                public String getTitledBorderText() {
0224:                    Border border = getBorder();
0225:                    return (border instanceof  TitledBorder) ? ((TitledBorder) border)
0226:                            .getTitle()
0227:                            : null;
0228:                }
0229:
0230:                @Override
0231:                public String getAccessibleName() {
0232:                    return super .getAccessibleName();
0233:                }
0234:
0235:                @Override
0236:                public String getAccessibleDescription() {
0237:                    String description = super .getAccessibleDescription();
0238:                    return (description == null) ? getToolTipText()
0239:                            : description;
0240:                }
0241:
0242:                @Override
0243:                public void removePropertyChangeListener(
0244:                        PropertyChangeListener listener) {
0245:                    super .removePropertyChangeListener(listener);
0246:                }
0247:
0248:                final AccessibleExtendedComponent getAccessibleExtendedComponent() {
0249:                    return this ;
0250:                }
0251:
0252:                @Override
0253:                public void addPropertyChangeListener(
0254:                        PropertyChangeListener listener) {
0255:                    super .addPropertyChangeListener(listener);
0256:                    if (accessibleContainerHandler == null) {
0257:                        accessibleContainerHandler = new AccessibleContainerHandler();
0258:                        addContainerListener(accessibleContainerHandler);
0259:                    }
0260:                    if (accessibleFocusHandler == null) {
0261:                        accessibleFocusHandler = new AccessibleFocusHandler();
0262:                        addFocusListener(accessibleFocusHandler);
0263:                    }
0264:                }
0265:
0266:                @Override
0267:                public int getAccessibleChildrenCount() {
0268:                    return super .getAccessibleChildrenCount();
0269:                }
0270:            }
0271:
0272:            private static final int FIRST_INPUT_MAP_INDEX = 0;
0273:
0274:            public static final int WHEN_FOCUSED = 0;
0275:
0276:            public static final int WHEN_ANCESTOR_OF_FOCUSED_COMPONENT = 1;
0277:
0278:            public static final int WHEN_IN_FOCUSED_WINDOW = 2;
0279:
0280:            private static final int LAST_INPUT_MAP_INDEX = 2;
0281:
0282:            public static final int UNDEFINED_CONDITION = -1;
0283:
0284:            public static final String TOOL_TIP_TEXT_KEY = "ToolTipText";
0285:
0286:            static final String INHERITS_POPUP_MENU_PROPERTY_NAME = "inheritsPopupMenu";
0287:
0288:            static final String COMPONENT_POPUP_MENU_PROPERTY_NAME = "componentPopupMenu";
0289:
0290:            static final String UI_PROPERTY_NAME = "UI";
0291:
0292:            static final String AUTOSCROLLS_PROPERTY_NAME = "autoscrolls";
0293:
0294:            static final String VERIFY_INPUT_PROPERTY_NAME = "verifyInputWhenFocusTarget";
0295:
0296:            static final String NEXT_FOCUSABLE_PROPERTY_NAME = "nextFocus";
0297:
0298:            private static final String INPUT_VERIFIER_PROPERTY_NAME = "inputVerifier";
0299:
0300:            protected AccessibleContext accessibleContext;
0301:
0302:            private final static String UI_CLASS_ID = "ComponentUI";
0303:
0304:            private static Locale defaultLocale;
0305:
0306:            protected transient ComponentUI ui;
0307:
0308:            private Float alignmentX;
0309:
0310:            private Float alignmentY;
0311:
0312:            private Border border;
0313:
0314:            private int debugGraphicsOptions;
0315:
0316:            private final HashMap<Object, Object> clientProperties = new HashMap<Object, Object>();
0317:
0318:            private TransferHandler transferHandler;
0319:
0320:            private ActionMap actionMap;
0321:
0322:            private boolean actionMapCreated;
0323:
0324:            private final InputMap[] inputMaps = new InputMap[3];
0325:
0326:            private final boolean[] inputMapsCreated = new boolean[3];
0327:
0328:            private transient AncestorComponentNotifier ancestorComponentNotifier;
0329:
0330:            private final VetoableChangeSupport vetoableChangeSupport = new VetoableChangeSupport(
0331:                    this );;
0332:
0333:            protected EventListenerList listenerList = new EventListenerList();
0334:
0335:            private boolean autoscrolls;
0336:
0337:            private Component nextFocusableComponent;
0338:
0339:            private boolean verifyInputWhenFocusTarget = true;
0340:
0341:            private InputVerifier inputVerifier;
0342:
0343:            private boolean requestFocusEnabled = true;
0344:
0345:            private boolean inheritsPopupMenu;
0346:
0347:            private JPopupMenu componentPopupMenu;
0348:
0349:            private static final String ILLEGAL_CONDITION_MESSAGE = Messages
0350:                    .getString(
0351:                            "swing.B3", "JComponent.WHEN_IN_FOCUSED_WINDOW, JComponent.WHEN_FOCUSED ", //$NON-NLS-1$ //$NON-NLS-2$
0352:                            "JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT"); //$NON-NLS-1$ 
0353:
0354:            private boolean opaque;
0355:
0356:            private boolean doubleBuffered;
0357:
0358:            private boolean doubleBufferingRoot;
0359:
0360:            private static final Rectangle auxRectangle = new Rectangle();
0361:
0362:            final Set<String> installablePropertiesExcluded = new HashSet<String>();
0363:
0364:            private static JToolTip toolTip;
0365:            static {
0366:                setDefaultLocale(Locale.getDefault());
0367:                KeyboardFocusManager.getCurrentKeyboardFocusManager()
0368:                        .addKeyEventPostProcessor(new KeyEventPostProcessor() {
0369:                            public boolean postProcessKeyEvent(KeyEvent event) {
0370:                                if (event.isConsumed()) {
0371:                                    return false;
0372:                                }
0373:                                final Component source = event.getComponent();
0374:                                Container parent = SwingUtilities
0375:                                        .getRootPane(source);
0376:                                while (parent != null) {
0377:                                    if (SwingUtilities
0378:                                            .processKeyEventOnComponent(parent,
0379:                                                    event)) {
0380:                                        return true;
0381:                                    }
0382:                                    if (SwingUtilities
0383:                                            .processKeyEventOnChildren(parent,
0384:                                                    event)) {
0385:                                        return true;
0386:                                    }
0387:                                    parent = SwingUtilities.getAncestorOfClass(
0388:                                            JRootPane.class, parent);
0389:                                }
0390:                                return false;
0391:                            }
0392:                        });
0393:            }
0394:
0395:            public JComponent() {
0396:                setLocale(getDefaultLocale());
0397:                enableEvents(AWTEvent.KEY_EVENT_MASK);
0398:            }
0399:
0400:            @Override
0401:            public Rectangle getBounds(Rectangle bounds) {
0402:                if (bounds == null) {
0403:                    return getBounds();
0404:                }
0405:                bounds.setBounds(getX(), getY(), getWidth(), getHeight());
0406:                return bounds;
0407:            }
0408:
0409:            @Override
0410:            public Point getLocation(Point extLocation) {
0411:                if (extLocation == null) {
0412:                    return getLocation();
0413:                }
0414:                extLocation.x = getX();
0415:                extLocation.y = getY();
0416:                return extLocation;
0417:            }
0418:
0419:            @Override
0420:            public Insets getInsets() {
0421:                return getInsets(null);
0422:            }
0423:
0424:            public Insets getInsets(Insets insets) {
0425:                Border border = getBorder();
0426:                if (border instanceof  AbstractBorder && insets != null) {
0427:                    return ((AbstractBorder) border).getBorderInsets(this ,
0428:                            insets);
0429:                }
0430:                Insets originalInsets;
0431:                if (border == null) {
0432:                    originalInsets = super .getInsets();
0433:                } else {
0434:                    originalInsets = border.getBorderInsets(this );
0435:                }
0436:                if (insets != null) {
0437:                    insets.set(originalInsets.top, originalInsets.left,
0438:                            originalInsets.bottom, originalInsets.right);
0439:                    return insets;
0440:                }
0441:                return originalInsets;
0442:            }
0443:
0444:            @Override
0445:            public Dimension getSize(Dimension extSize) {
0446:                if (extSize == null) {
0447:                    return getSize();
0448:                }
0449:                extSize.setSize(getWidth(), getHeight());
0450:                return extSize;
0451:            }
0452:
0453:            @Override
0454:            public Dimension getMinimumSize() {
0455:                if (isMinimumSizeSet()) {
0456:                    return super .getMinimumSize();
0457:                }
0458:                if (ui != null) {
0459:                    Dimension size = ui.getMinimumSize(this );
0460:                    if (size != null) {
0461:                        return new Dimension(size);
0462:                    }
0463:                }
0464:                LayoutManager layout = getLayout();
0465:                if (layout != null) {
0466:                    return layout.minimumLayoutSize(this );
0467:                }
0468:                return new Dimension();
0469:            }
0470:
0471:            @Override
0472:            public Dimension getMaximumSize() {
0473:                if (isMaximumSizeSet()) {
0474:                    return super .getMaximumSize();
0475:                }
0476:                if (ui != null) {
0477:                    Dimension size = ui.getMaximumSize(this );
0478:                    if (size != null) {
0479:                        return new Dimension(size);
0480:                    }
0481:                }
0482:                LayoutManager layout = getLayout();
0483:                if (layout != null && layout instanceof  LayoutManager2) {
0484:                    return ((LayoutManager2) layout).maximumLayoutSize(this );
0485:                }
0486:                return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
0487:            }
0488:
0489:            @Override
0490:            public Dimension getPreferredSize() {
0491:                if (isPreferredSizeSet()) {
0492:                    return super .getPreferredSize();
0493:                }
0494:                if (ui != null) {
0495:                    Dimension size = ui.getPreferredSize(this );
0496:                    if (size != null) {
0497:                        return new Dimension(size);
0498:                    }
0499:                }
0500:                if (getLayout() != null) {
0501:                    return getLayout().preferredLayoutSize(this );
0502:                }
0503:                return new Dimension();
0504:            }
0505:
0506:            @Override
0507:            public boolean contains(int x, int y) {
0508:                return (ui != null) ? ui.contains(this , x, y) : super .contains(
0509:                        x, y);
0510:            }
0511:
0512:            public final void putClientProperty(Object key, Object value) {
0513:                if (key == null) {
0514:                    throw new NullPointerException();
0515:                }
0516:
0517:                Object oldValue = (value != null) ? clientProperties.put(key,
0518:                        value) : clientProperties.remove(key);
0519:                if (oldValue != value) {
0520:                    firePropertyChange((key != null) ? key.toString() : null,
0521:                            oldValue, value);
0522:                }
0523:            }
0524:
0525:            public final Object getClientProperty(Object key) {
0526:                return clientProperties.get(key);
0527:            }
0528:
0529:            @Override
0530:            public void firePropertyChange(String propertyName,
0531:                    boolean oldValue, boolean newValue) {
0532:                super .firePropertyChange(propertyName, oldValue, newValue);
0533:            }
0534:
0535:            @Override
0536:            public void firePropertyChange(String propertyName, int oldValue,
0537:                    int newValue) {
0538:                super .firePropertyChange(propertyName, oldValue, newValue);
0539:            }
0540:
0541:            protected void fireVetoableChange(String property, Object oldValue,
0542:                    Object newValue) throws PropertyVetoException {
0543:                vetoableChangeSupport.fireVetoableChange(property, oldValue,
0544:                        newValue);
0545:            }
0546:
0547:            @SuppressWarnings("unchecked")
0548:            @Override
0549:            public <T extends EventListener> T[] getListeners(
0550:                    Class<T> listenersClass) {
0551:                T[] result = super .getListeners(listenersClass);
0552:                if (!Utilities.isEmptyArray(result)) {
0553:                    return result;
0554:                }
0555:                result = listenerList.getListeners(listenersClass);
0556:                if (!Utilities.isEmptyArray(result)) {
0557:                    return result;
0558:                }
0559:                if (VetoableChangeListener.class
0560:                        .isAssignableFrom(listenersClass)) {
0561:                    result = (T[]) getVetoableChangeListeners();
0562:                }
0563:                return result;
0564:            }
0565:
0566:            public void removeAncestorListener(AncestorListener ancestorListener) {
0567:                listenerList.remove(AncestorListener.class, ancestorListener);
0568:                removeAncestorComponentNotifier();
0569:            }
0570:
0571:            public void addAncestorListener(AncestorListener ancestorListener) {
0572:                addAncestorComponentNotifier();
0573:                listenerList.add(AncestorListener.class, ancestorListener);
0574:            }
0575:
0576:            public AncestorListener[] getAncestorListeners() {
0577:                return getListeners(AncestorListener.class);
0578:            }
0579:
0580:            public synchronized void removeVetoableChangeListener(
0581:                    VetoableChangeListener listener) {
0582:                vetoableChangeSupport.removeVetoableChangeListener(listener);
0583:            }
0584:
0585:            public synchronized void addVetoableChangeListener(
0586:                    VetoableChangeListener listener) {
0587:                vetoableChangeSupport.addVetoableChangeListener(listener);
0588:            }
0589:
0590:            public synchronized VetoableChangeListener[] getVetoableChangeListeners() {
0591:                return vetoableChangeSupport.getVetoableChangeListeners();
0592:            }
0593:
0594:            public void registerKeyboardAction(ActionListener action,
0595:                    String command, KeyStroke keyStroke, int condition) {
0596:                String commandKey = (command != null) ? command
0597:                        : ((action != null) ? action.toString() : "");
0598:                getInputMap(condition, true).put(keyStroke, commandKey);
0599:                Action actionProxy = action instanceof  Action ? (Action) action
0600:                        : new ActionProxy(command, action);
0601:                getActionMap(true).put(commandKey, actionProxy);
0602:            }
0603:
0604:            public void registerKeyboardAction(ActionListener action,
0605:                    KeyStroke keyStroke, int condition) {
0606:                registerKeyboardAction(action, null, keyStroke, condition);
0607:            }
0608:
0609:            public void unregisterKeyboardAction(KeyStroke keyStroke) {
0610:                for (int i = FIRST_INPUT_MAP_INDEX; i <= LAST_INPUT_MAP_INDEX; i++) {
0611:                    if (inputMaps[i] != null) {
0612:                        Object command = inputMaps[i].get(keyStroke);
0613:                        inputMaps[i].remove(keyStroke);
0614:                        if (actionMap != null) {
0615:                            actionMap.remove(command);
0616:                        }
0617:                    }
0618:                }
0619:            }
0620:
0621:            public int getConditionForKeyStroke(KeyStroke keyStroke) {
0622:                for (int i = FIRST_INPUT_MAP_INDEX; i <= LAST_INPUT_MAP_INDEX; i++) {
0623:                    if (inputMaps[i] != null
0624:                            && inputMaps[i].get(keyStroke) != null) {
0625:                        return i;
0626:                    }
0627:                }
0628:                return UNDEFINED_CONDITION;
0629:            }
0630:
0631:            public ActionListener getActionForKeyStroke(KeyStroke keyStroke) {
0632:                Object command = null;
0633:                for (int i = FIRST_INPUT_MAP_INDEX; i <= LAST_INPUT_MAP_INDEX
0634:                        && (command == null); i++) {
0635:                    if (inputMaps[i] != null) {
0636:                        command = inputMaps[i].get(keyStroke);
0637:                    }
0638:                }
0639:                ActionListener action = (command != null && actionMap != null) ? actionMap
0640:                        .get(command)
0641:                        : null;
0642:                return (action instanceof  ActionProxy) ? (ActionListener) ((ActionProxy) action)
0643:                        .getValue(Action.NAME)
0644:                        : action;
0645:            }
0646:
0647:            protected boolean processKeyBinding(KeyStroke keyStroke,
0648:                    KeyEvent keyEvent, int condition, boolean pressed) {
0649:                InputMap inputMap = getInputMap(condition, false);
0650:                if (inputMap == null || actionMap == null || !isEnabled()) {
0651:                    return false;
0652:                }
0653:                Object command = inputMap.get(keyStroke);
0654:                if (command == null) {
0655:                    return false;
0656:                }
0657:                Action action = actionMap.get(command);
0658:                return SwingUtilities.notifyAction(action, keyStroke, keyEvent,
0659:                        this , keyEvent.getModifiersEx());
0660:            }
0661:
0662:            public KeyStroke[] getRegisteredKeyStrokes() {
0663:                ArrayList<KeyStroke> allKeys = new ArrayList<KeyStroke>();
0664:                for (int i = FIRST_INPUT_MAP_INDEX; i <= LAST_INPUT_MAP_INDEX; i++) {
0665:                    if (inputMaps[i] != null) {
0666:                        KeyStroke[] keys = inputMaps[i].allKeys();
0667:                        if (keys != null) {
0668:                            allKeys.addAll(Arrays.asList(keys));
0669:                        }
0670:                    }
0671:                }
0672:                return allKeys.toArray(new KeyStroke[allKeys.size()]);
0673:            }
0674:
0675:            public void resetKeyboardActions() {
0676:                for (int i = FIRST_INPUT_MAP_INDEX; i <= LAST_INPUT_MAP_INDEX; i++) {
0677:                    if (inputMaps[i] != null) {
0678:                        inputMaps[i].clear();
0679:                    }
0680:                }
0681:                if (actionMap != null) {
0682:                    actionMap.clear();
0683:                }
0684:            }
0685:
0686:            public void setTransferHandler(TransferHandler newHandler) {
0687:                TransferHandler oldHandler = transferHandler;
0688:                transferHandler = newHandler;
0689:                if (!Boolean.valueOf(
0690:                        System.getProperty("suppressSwingDropSupport"))
0691:                        .booleanValue()) {
0692:                    new DropTarget(this , null);
0693:                }
0694:                firePropertyChange(
0695:                        StringConstants.TRANSFER_HANDLER_PROPERTY_NAME,
0696:                        oldHandler, newHandler);
0697:            }
0698:
0699:            public TransferHandler getTransferHandler() {
0700:                return transferHandler;
0701:            }
0702:
0703:            public Container getTopLevelAncestor() {
0704:                for (Container parent = getParent(); parent != null; parent = parent
0705:                        .getParent()) {
0706:                    if (parent instanceof  Window || parent instanceof  Applet) {
0707:                        return parent;
0708:                    }
0709:                }
0710:                return null;
0711:            }
0712:
0713:            public JRootPane getRootPane() {
0714:                return (JRootPane) SwingUtilities.getAncestorOfClass(
0715:                        JRootPane.class, this );
0716:            }
0717:
0718:            public void setInputVerifier(InputVerifier verifier) {
0719:                InputVerifier oldValue = inputVerifier;
0720:                inputVerifier = verifier;
0721:                firePropertyChange(INPUT_VERIFIER_PROPERTY_NAME, oldValue,
0722:                        inputVerifier);
0723:            }
0724:
0725:            public InputVerifier getInputVerifier() {
0726:                return inputVerifier;
0727:            }
0728:
0729:            public final void setInputMap(int condition, InputMap map) {
0730:                if (condition == WHEN_IN_FOCUSED_WINDOW
0731:                        && !(map instanceof  ComponentInputMap) && map != null) {
0732:                    throw new IllegalArgumentException(Messages.getString(
0733:                            "swing.0D", "WHEN_IN_FOCUSED_WINDOW")); //$NON-NLS-1$ //$NON-NLS-2$
0734:                }
0735:                if (condition < FIRST_INPUT_MAP_INDEX
0736:                        || condition > LAST_INPUT_MAP_INDEX) {
0737:                    throw new IllegalArgumentException(
0738:                            ILLEGAL_CONDITION_MESSAGE);
0739:                }
0740:                inputMaps[condition] = map;
0741:                inputMapsCreated[condition] = true;
0742:            }
0743:
0744:            public final InputMap getInputMap(int condition) {
0745:                return getInputMap(condition, true);
0746:            }
0747:
0748:            public final InputMap getInputMap() {
0749:                return getInputMap(WHEN_FOCUSED, true);
0750:            }
0751:
0752:            final InputMap getInputMap(int condition, boolean forceCreate) {
0753:                if (condition < FIRST_INPUT_MAP_INDEX
0754:                        || condition > LAST_INPUT_MAP_INDEX) {
0755:                    throw new IllegalArgumentException(
0756:                            ILLEGAL_CONDITION_MESSAGE);
0757:                }
0758:                if (!forceCreate || inputMapsCreated[condition]) {
0759:                    return inputMaps[condition];
0760:                }
0761:                InputMap result = (condition != WHEN_IN_FOCUSED_WINDOW) ? new InputMap()
0762:                        : new ComponentInputMap(this );
0763:                inputMaps[condition] = result;
0764:                inputMapsCreated[condition] = true;
0765:                return result;
0766:            }
0767:
0768:            public final void setActionMap(ActionMap newActionMap) {
0769:                actionMapCreated = true;
0770:                actionMap = newActionMap;
0771:            }
0772:
0773:            public final ActionMap getActionMap() {
0774:                return getActionMap(true);
0775:            }
0776:
0777:            final ActionMap getActionMap(boolean forceCreate) {
0778:                if (forceCreate && !actionMapCreated) {
0779:                    actionMapCreated = true;
0780:                    actionMap = new ActionMap();
0781:                }
0782:                return actionMap;
0783:            }
0784:
0785:            public Border getBorder() {
0786:                return border;
0787:            }
0788:
0789:            public void setBorder(Border newBorder) {
0790:                if (newBorder != border) {
0791:                    Border oldBorder = border;
0792:                    border = newBorder;
0793:                    firePropertyChange(StringConstants.BORDER_PROPERTY_CHANGED,
0794:                            oldBorder, newBorder);
0795:                    if (oldBorder == null
0796:                            || newBorder == null
0797:                            || !oldBorder.getBorderInsets(this ).equals(
0798:                                    newBorder.getBorderInsets(this ))) {
0799:                        revalidate();
0800:                    }
0801:                    repaint();
0802:                }
0803:            }
0804:
0805:            public void setToolTipText(String text) {
0806:                putClientProperty(TOOL_TIP_TEXT_KEY, text);
0807:                if (text != null) {
0808:                    ToolTipManager.sharedInstance().registerComponent(this );
0809:                } else {
0810:                    ToolTipManager.sharedInstance().unregisterComponent(this );
0811:                }
0812:            }
0813:
0814:            public String getToolTipText() {
0815:                return (String) getClientProperty(TOOL_TIP_TEXT_KEY);
0816:            }
0817:
0818:            public String getToolTipText(MouseEvent event) {
0819:                return getToolTipText();
0820:            }
0821:
0822:            public JToolTip createToolTip() {
0823:                if (toolTip == null) {
0824:                    toolTip = new JToolTip();
0825:                }
0826:                toolTip.setComponent(this );
0827:                return toolTip;
0828:            }
0829:
0830:            public Point getToolTipLocation(MouseEvent event) {
0831:                return null;
0832:            }
0833:
0834:            public String getUIClassID() {
0835:                return UI_CLASS_ID;
0836:            }
0837:
0838:            @Override
0839:            protected void processKeyEvent(KeyEvent event) {
0840:                super .processKeyEvent(event);
0841:                if (!event.isConsumed()) {
0842:                    processComponentKeyEvent(event);
0843:                }
0844:                if (!event.isConsumed() && processKeyBindings(event, this )) {
0845:                    event.consume();
0846:                }
0847:            }
0848:
0849:            static boolean processKeyBindings(KeyEvent event, Component source) {
0850:                boolean pressed = (event.getID() == KeyEvent.KEY_PRESSED);
0851:                final KeyStroke ks = KeyStroke.getKeyStrokeForEvent(event);
0852:                Component component = source;
0853:                if (component instanceof  JComponent) {
0854:                    if (((JComponent) component).processKeyBinding(ks, event,
0855:                            JComponent.WHEN_FOCUSED, pressed)) {
0856:                        return true;
0857:                    }
0858:                }
0859:                while (component != null) {
0860:                    if (component instanceof  JComponent) {
0861:                        if (((JComponent) component).processKeyBinding(ks,
0862:                                event,
0863:                                JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
0864:                                pressed)) {
0865:                            return true;
0866:                        }
0867:                    }
0868:                    component = component.getParent();
0869:                }
0870:                component = KeyboardFocusManager
0871:                        .getCurrentKeyboardFocusManager().getFocusOwner();
0872:                if (component == null) {
0873:                    component = source;
0874:                }
0875:                Window w = SwingUtilities.getWindowAncestor(component);
0876:                if (w != null) {
0877:                    if (SwingUtilities.processKeyEventOnChildren(w, event)) {
0878:                        event.consume();
0879:                        return true;
0880:                    }
0881:                }
0882:                return false;
0883:            }
0884:
0885:            final void componentInputMapChanged(ComponentInputMap map) {
0886:            }
0887:
0888:            protected void processComponentKeyEvent(KeyEvent event) {
0889:            }
0890:
0891:            @Override
0892:            public void addNotify() {
0893:                super .addNotify();
0894:                firePropertyChange(StringConstants.ANCESTOR_PROPERTY_NAME,
0895:                        null, getParent());
0896:            }
0897:
0898:            @Override
0899:            public void removeNotify() {
0900:                firePropertyChange(StringConstants.ANCESTOR_PROPERTY_NAME,
0901:                        getParent(), null);
0902:                super .removeNotify();
0903:            }
0904:
0905:            public void scrollRectToVisible(Rectangle rect) {
0906:                Container parent = SwingUtilities.getAncestorOfClass(
0907:                        JComponent.class, this );
0908:                if (parent == null) {
0909:                    return;
0910:                }
0911:                Rectangle translatedRect = SwingUtilities.convertRectangle(
0912:                        this , rect, parent);
0913:                ((JComponent) parent).scrollRectToVisible(translatedRect);
0914:            }
0915:
0916:            public void computeVisibleRect(Rectangle rect) {
0917:                rect.setBounds(0, 0, getWidth(), getHeight());
0918:                getComponentVisibleRect(this , rect);
0919:            }
0920:
0921:            public Rectangle getVisibleRect() {
0922:                return getComponentVisibleRect(this , new Rectangle(getWidth(),
0923:                        getHeight()));
0924:            }
0925:
0926:            @Override
0927:            public void update(Graphics graphics) {
0928:                paint(graphics);
0929:            }
0930:
0931:            protected void printComponent(Graphics g) {
0932:                paintComponent(g);
0933:            }
0934:
0935:            protected void printChildren(Graphics g) {
0936:                paintChildren(g);
0937:            }
0938:
0939:            protected void printBorder(Graphics g) {
0940:                paintBorder(g);
0941:            }
0942:
0943:            @Override
0944:            public void printAll(Graphics g) {
0945:                print(g);
0946:            }
0947:
0948:            @Override
0949:            public void print(Graphics g) {
0950:                setDoubleBuffered(false);
0951:                printComponent(g);
0952:                printBorder(g);
0953:                printChildren(g);
0954:                setDoubleBuffered(true);
0955:            }
0956:
0957:            protected void paintComponent(Graphics graphics) {
0958:                if (ui != null) {
0959:                    Graphics uiGraphics = graphics.create();
0960:                    ui.update(uiGraphics, this );
0961:                    uiGraphics.dispose();
0962:                }
0963:            }
0964:
0965:            protected void paintChildren(Graphics graphics) {
0966:                Rectangle clipBounds = graphics.getClipBounds();
0967:                if (clipBounds != null && clipBounds.isEmpty()) {
0968:                    return;
0969:                }
0970:                int cc = getComponentCount();
0971:                if (!isOptimizedDrawingEnabled()) {
0972:                    MultiRectArea childrenCoverage = null;
0973:                    Component compList[] = new Component[cc];
0974:                    Shape clipList[] = new Shape[cc];
0975:                    int rc = -1;
0976:                    for (int i = 0; i < cc; i++) {
0977:                        Component comp = getComponent(i);
0978:                        if (comp.isVisible()) {
0979:                            if (!comp.isLightweight()) {
0980:                                continue;
0981:                            }
0982:                            MultiRectArea clip;
0983:                            Rectangle bounds = comp.getBounds();
0984:                            if (childrenCoverage == null && comp.isOpaque()) {
0985:                                childrenCoverage = new MultiRectArea(bounds);
0986:                                clip = new MultiRectArea(bounds);
0987:                            } else {
0988:                                clip = new MultiRectArea(bounds);
0989:                                clip.substract(childrenCoverage);
0990:                                if (clip.isEmpty()) {
0991:                                    continue;
0992:                                }
0993:                                if (comp.isOpaque()) {
0994:                                    childrenCoverage = MultiRectArea.union(
0995:                                            childrenCoverage, clip);
0996:                                }
0997:                            }
0998:                            rc++;
0999:                            if (clipBounds != null) {
1000:                                clip.intersect(clipBounds);
1001:                            }
1002:                            clip.translate(-bounds.x, -bounds.y);
1003:                            compList[rc] = comp;
1004:                            clipList[rc] = clip;
1005:                        }
1006:                    }
1007:                    while (rc >= 0) {
1008:                        Component comp = compList[rc];
1009:                        Graphics gComp = getChildJComponentGraphics(graphics,
1010:                                comp);
1011:                        if (gComp != null) {
1012:                            ((Graphics2D) gComp).clip(clipList[rc]);
1013:                            if (!gComp.getClipBounds().isEmpty()) {
1014:                                comp.paint(gComp);
1015:                            }
1016:                            gComp.dispose();
1017:                        }
1018:                        rc--;
1019:                    }
1020:                } else {
1021:                    for (int i = cc - 1; i >= 0; i--) {
1022:                        Component comp = getComponent(i);
1023:                        if (comp.isVisible()) {
1024:                            if (!comp.isLightweight()) {
1025:                                continue;
1026:                            }
1027:                            Graphics gComp = getChildJComponentGraphics(
1028:                                    graphics, comp);
1029:                            if (gComp != null) {
1030:                                Rectangle bounds = comp.getBounds();
1031:                                int x = bounds.x;
1032:                                int y = bounds.y;
1033:                                if (clipBounds != null) {
1034:                                    bounds = bounds.intersection(clipBounds);
1035:                                }
1036:                                bounds.translate(-x, -y);
1037:                                gComp.clipRect(bounds.x, bounds.y,
1038:                                        bounds.width, bounds.height);
1039:                                if (!gComp.getClipBounds().isEmpty()) {
1040:                                    comp.paint(gComp);
1041:                                }
1042:                                gComp.dispose();
1043:                            }
1044:                        }
1045:                    }
1046:                }
1047:            }
1048:
1049:            protected void paintBorder(Graphics graphics) {
1050:                if (border != null) {
1051:                    border.paintBorder(this , graphics, 0, 0, getWidth(),
1052:                            getHeight());
1053:                }
1054:            }
1055:
1056:            @Override
1057:            public void paint(Graphics graphics) {
1058:                if (RepaintManager.currentManager(this )
1059:                        .isDoubleBufferingEnabled()
1060:                        && isDoubleBuffered()
1061:                        && isOpaque()
1062:                        && !insideDoubleBuffering()) {
1063:                    paintDoubleBuffered(graphics);
1064:                } else {
1065:                    paintComponent(graphics);
1066:                    paintBorder(graphics);
1067:                    paintChildren(graphics);
1068:                }
1069:            }
1070:
1071:            public void repaint(Rectangle rect) {
1072:                RepaintManager.currentManager(this ).addDirtyRegion(this ,
1073:                        rect.x, rect.y, rect.width, rect.height);
1074:            }
1075:
1076:            @Override
1077:            public void repaint(long tm, int x, int y, int width, int height) {
1078:                RepaintManager.currentManager(this ).addDirtyRegion(this , x, y,
1079:                        width, height);
1080:            }
1081:
1082:            public void paintImmediately(Rectangle rect) {
1083:                if (rect == null) {
1084:                    throw new NullPointerException();
1085:                }
1086:
1087:                if (!isShowing()) {
1088:                    return;
1089:                }
1090:                Component effectiveRoot = Utilities.getDrawingRoot(this , rect);
1091:                while (effectiveRoot != null
1092:                        && !(effectiveRoot instanceof  Window)
1093:                        && !effectiveRoot.isOpaque()) {
1094:                    effectiveRoot = effectiveRoot.getParent();
1095:                }
1096:                if (effectiveRoot == null) {
1097:                    return;
1098:                }
1099:                Graphics g = effectiveRoot.getGraphics();
1100:                if (g == null) {
1101:                    return;
1102:                }
1103:                Rectangle visibleRect = getComponentVisibleRect(effectiveRoot,
1104:                        new Rectangle(effectiveRoot.getWidth(), effectiveRoot
1105:                                .getHeight()));
1106:                if (rect instanceof  ClipRegion) {
1107:                    ClipRegion repaintRegion = (ClipRegion) rect;
1108:                    repaintRegion.convertRegion(this , effectiveRoot);
1109:                    repaintRegion.intersect(visibleRect);
1110:                    if (repaintRegion.isEmpty()) {
1111:                        g.dispose();
1112:                        return;
1113:                    }
1114:                    if (g instanceof  Graphics2D) {
1115:                        ((Graphics2D) g).clip(repaintRegion.getClip());
1116:                    } else {
1117:                        g.setClip(repaintRegion.getClip());
1118:                    }
1119:                } else {
1120:                    Rectangle repaintRect = SwingUtilities.convertRectangle(
1121:                            this , rect, effectiveRoot);
1122:                    repaintRect = SwingUtilities.computeIntersection(
1123:                            repaintRect.x, repaintRect.y, repaintRect.width,
1124:                            repaintRect.height, visibleRect);
1125:                    if (repaintRect.isEmpty()) {
1126:                        g.dispose();
1127:                        return;
1128:                    }
1129:                    g.clipRect(rect.x, rect.y, rect.width, rect.height);
1130:                }
1131:                if (RepaintManager.currentManager(this )
1132:                        .isDoubleBufferingEnabled()
1133:                        && effectiveRoot instanceof  JComponent
1134:                        && isDoubleBufferingEnabled(effectiveRoot)) {
1135:                    ((JComponent) effectiveRoot).paintDoubleBuffered(g);
1136:                } else {
1137:                    effectiveRoot.paint(g);
1138:                }
1139:                g.dispose();
1140:            }
1141:
1142:            public void paintImmediately(int x, int y, int width, int height) {
1143:                paintImmediately(new Rectangle(x, y, width, height));
1144:            }
1145:
1146:            @Override
1147:            public Graphics getGraphics() {
1148:                Graphics result = super .getGraphics();
1149:                if (result != null) {
1150:                    result = getComponentGraphics(result);
1151:                }
1152:                return result;
1153:            }
1154:
1155:            protected Graphics getComponentGraphics(Graphics g) {
1156:                Graphics result = null;
1157:                if (debugGraphicsOptions == 0) {
1158:                    result = g;
1159:                } else {
1160:                    result = new DebugGraphics(g);
1161:                    ((DebugGraphics) result)
1162:                            .setDebugOptions(debugGraphicsOptions);
1163:                }
1164:                result.setFont(getFont());
1165:                result.setColor(getForeground());
1166:                ((Graphics2D) result).setBackground(getBackground());
1167:                return result;
1168:            }
1169:
1170:            public void setNextFocusableComponent(Component component) {
1171:                Component oldComponent = nextFocusableComponent;
1172:                nextFocusableComponent = component;
1173:                firePropertyChange(NEXT_FOCUSABLE_PROPERTY_NAME, oldComponent,
1174:                        nextFocusableComponent);
1175:                Container focusCycleRoot = getFocusCycleRootAncestor();
1176:                if (focusCycleRoot == null) {
1177:                    return;
1178:                }
1179:                FocusTraversalPolicy newFocusTraversalPolicy = new BequestedFocusTraversalPolicy(
1180:                        focusCycleRoot.getFocusTraversalPolicy(), this ,
1181:                        nextFocusableComponent);
1182:                focusCycleRoot.setFocusTraversalPolicy(newFocusTraversalPolicy);
1183:            }
1184:
1185:            public Component getNextFocusableComponent() {
1186:                return nextFocusableComponent;
1187:            }
1188:
1189:            public void setVerifyInputWhenFocusTarget(boolean verifyInput) {
1190:                boolean oldValue = verifyInputWhenFocusTarget;
1191:                verifyInputWhenFocusTarget = verifyInput;
1192:                firePropertyChange(VERIFY_INPUT_PROPERTY_NAME, oldValue,
1193:                        verifyInputWhenFocusTarget);
1194:            }
1195:
1196:            public boolean getVerifyInputWhenFocusTarget() {
1197:                return verifyInputWhenFocusTarget;
1198:            }
1199:
1200:            public void setRequestFocusEnabled(boolean enabled) {
1201:                requestFocusEnabled = enabled;
1202:            }
1203:
1204:            public boolean isRequestFocusEnabled() {
1205:                return requestFocusEnabled;
1206:            }
1207:
1208:            private boolean checkRequestedFocus() {
1209:                if (!getVerifyInputWhenFocusTarget()) {
1210:                    return true;
1211:                }
1212:                Component focusOwner = KeyboardFocusManager
1213:                        .getCurrentKeyboardFocusManager().getFocusOwner();
1214:                if (focusOwner == this ) {
1215:                    return true;
1216:                }
1217:                if (!(focusOwner instanceof  JComponent)) {
1218:                    return true;
1219:                }
1220:                JComponent jFocusOwner = ((JComponent) focusOwner);
1221:                InputVerifier verifier = jFocusOwner.getInputVerifier();
1222:                if (verifier != null) {
1223:                    return verifier.verify(jFocusOwner);
1224:                }
1225:                return true;
1226:            }
1227:
1228:            @Override
1229:            public void requestFocus() {
1230:                if (checkRequestedFocus()) {
1231:                    super .requestFocus();
1232:                }
1233:            }
1234:
1235:            @Override
1236:            public boolean requestFocus(boolean temporary) {
1237:                if (!checkRequestedFocus()) {
1238:                    return false;
1239:                }
1240:                return super .requestFocus(temporary);
1241:            }
1242:
1243:            @Override
1244:            public boolean requestFocusInWindow() {
1245:                if (!checkRequestedFocus()) {
1246:                    return false;
1247:                }
1248:                return super .requestFocusInWindow();
1249:            }
1250:
1251:            @Override
1252:            protected boolean requestFocusInWindow(boolean temporary) {
1253:                if (!checkRequestedFocus()) {
1254:                    return false;
1255:                }
1256:                return super .requestFocusInWindow(temporary);
1257:            }
1258:
1259:            public boolean requestDefaultFocus() {
1260:                Component defaultComponent = null;
1261:                Container cycleRoot = isFocusCycleRoot() ? this 
1262:                        : getFocusCycleRootAncestor();
1263:                if (cycleRoot != null) {
1264:                    defaultComponent = cycleRoot.getFocusTraversalPolicy()
1265:                            .getDefaultComponent(this );
1266:                }
1267:                if (defaultComponent == null) {
1268:                    return false;
1269:                }
1270:                defaultComponent.requestFocus();
1271:                return true;
1272:            }
1273:
1274:            public boolean isManagingFocus() {
1275:                return false;
1276:            }
1277:
1278:            public void grabFocus() {
1279:                requestFocus();
1280:            }
1281:
1282:            public void setOpaque(boolean opaque) {
1283:                LookAndFeel.markPropertyNotInstallable(this ,
1284:                        StringConstants.OPAQUE_PROPERTY);
1285:                if (this .opaque != opaque) {
1286:                    boolean oldOpaque = this .opaque;
1287:                    this .opaque = opaque;
1288:                    repaint();
1289:                    firePropertyChange(StringConstants.OPAQUE_PROPERTY,
1290:                            oldOpaque, opaque);
1291:                }
1292:            }
1293:
1294:            @Override
1295:            public void setEnabled(boolean enabled) {
1296:                boolean oldEnabledValue = isEnabled();
1297:                super .setEnabled(enabled);
1298:                firePropertyChange(StringConstants.ENABLED_PROPERTY_CHANGED,
1299:                        oldEnabledValue, enabled);
1300:                if (oldEnabledValue != enabled) {
1301:                    repaint();
1302:                }
1303:            }
1304:
1305:            public void setDoubleBuffered(boolean flag) {
1306:                doubleBuffered = flag;
1307:            }
1308:
1309:            public void setDebugGraphicsOptions(int newDebugGraphicsOptions) {
1310:                debugGraphicsOptions = (newDebugGraphicsOptions != DebugGraphics.NONE_OPTION) ? newDebugGraphicsOptions
1311:                        : 0;
1312:            }
1313:
1314:            @Override
1315:            public float getAlignmentY() {
1316:                return (alignmentY != null) ? alignmentY.floatValue() : 0.5f;
1317:            }
1318:
1319:            @Override
1320:            public float getAlignmentX() {
1321:                return (alignmentX != null) ? alignmentX.floatValue() : 0.5f;
1322:            }
1323:
1324:            public void setAlignmentY(float alignment) {
1325:                alignmentY = new Float((alignment < 0) ? 0
1326:                        : ((alignment > 1.0f) ? 1.0f : alignment));
1327:            }
1328:
1329:            public void setAlignmentX(float alignment) {
1330:                alignmentX = new Float((alignment < 0) ? 0
1331:                        : ((alignment > 1.0f) ? 1.0f : alignment));
1332:            }
1333:
1334:            public boolean isValidateRoot() {
1335:                return false;
1336:            }
1337:
1338:            public void revalidate() {
1339:                invalidate();
1340:                RepaintManager.currentManager(this ).addInvalidComponent(this );
1341:            }
1342:
1343:            public boolean isPaintingTile() {
1344:                return false;
1345:            }
1346:
1347:            public boolean isOptimizedDrawingEnabled() {
1348:                return true;
1349:            }
1350:
1351:            @Override
1352:            public boolean isOpaque() {
1353:                return opaque;
1354:            }
1355:
1356:            @Override
1357:            public boolean isDoubleBuffered() {
1358:                return doubleBuffered;
1359:            }
1360:
1361:            public void setAutoscrolls(boolean scrolls) {
1362:                LookAndFeel.markPropertyNotInstallable(this ,
1363:                        AUTOSCROLLS_PROPERTY_NAME);
1364:                autoscrolls = scrolls;
1365:            }
1366:
1367:            public boolean getAutoscrolls() {
1368:                return autoscrolls;
1369:            }
1370:
1371:            protected void setUI(ComponentUI newUI) {
1372:                ComponentUI oldUI = ui;
1373:                if (ui != null) {
1374:                    ui.uninstallUI(this );
1375:                }
1376:                ui = newUI;
1377:                if (ui != null) {
1378:                    ui.installUI(this );
1379:                }
1380:                revalidate();
1381:                repaint();
1382:                firePropertyChange(UI_PROPERTY_NAME, oldUI, newUI);
1383:            }
1384:
1385:            public void updateUI() {
1386:                if (UIManager.get(getUIClassID()) != null) {
1387:                    setUI(UIManager.getUI(this ));
1388:                }
1389:            }
1390:
1391:            public int getDebugGraphicsOptions() {
1392:                return debugGraphicsOptions;
1393:            }
1394:
1395:            public static void setDefaultLocale(Locale locale) {
1396:                defaultLocale = locale;
1397:            }
1398:
1399:            public static Locale getDefaultLocale() {
1400:                return defaultLocale;
1401:            }
1402:
1403:            public static boolean isLightweightComponent(Component component) {
1404:                return component.isLightweight();
1405:            }
1406:
1407:            private boolean isOfPrintableType(Object obj) {
1408:                return (obj instanceof  Boolean || obj instanceof  Point
1409:                        || obj instanceof  Insets || obj instanceof  Rectangle
1410:                        || obj instanceof  Dimension || obj instanceof  Number || obj instanceof  String);
1411:            }
1412:
1413:            private boolean isDefaultValue(Object obj, Class<?> clazz) {
1414:                if (obj == null) {
1415:                    return true;
1416:                }
1417:                if (obj.getClass() == clazz) {
1418:                    return false;
1419:                }
1420:                if (obj instanceof  Boolean && !((Boolean) obj).booleanValue()) {
1421:                    return true;
1422:                }
1423:                if (obj instanceof  Number && ((Number) obj).doubleValue() == 0) {
1424:                    return true;
1425:                }
1426:                return false;
1427:            }
1428:
1429:            @Override
1430:            protected String paramString() {
1431:                String result = "";
1432:                boolean addComma = false;
1433:                try {
1434:                    BeanInfo beanInfo = Introspector.getBeanInfo(getClass(),
1435:                            Container.class);
1436:                    for (int i = 0; i < beanInfo.getPropertyDescriptors().length; i++) {
1437:                        PropertyDescriptor descriptor = beanInfo
1438:                                .getPropertyDescriptors()[i];
1439:                        if (descriptor.getReadMethod() != null
1440:                                && descriptor.getWriteMethod() != null) {
1441:                            String fieldName = descriptor.getName();
1442:                            Class<?> type = descriptor.getPropertyType();
1443:                            Object fieldValue = descriptor.getReadMethod()
1444:                                    .invoke(this );
1445:                            if (isDefaultValue(fieldValue, type)) {
1446:                                continue;
1447:                            }
1448:                            if (addComma) {
1449:                                result += ",";
1450:                            }
1451:                            result += fieldName + "=";
1452:                            if (isOfPrintableType(fieldValue)) {
1453:                                result += fieldValue;
1454:                            } else {
1455:                                result += fieldValue.getClass().getName() + '@'
1456:                                        + System.identityHashCode(fieldValue);
1457:                            }
1458:                            addComma = true;
1459:                        }
1460:                    }
1461:                } catch (IntrospectionException e) {
1462:                } catch (IllegalArgumentException e) {
1463:                } catch (IllegalAccessException e) {
1464:                } catch (InvocationTargetException e) {
1465:                }
1466:                return result;
1467:            }
1468:
1469:            public void setInheritsPopupMenu(boolean value) {
1470:                boolean oldValue = inheritsPopupMenu;
1471:                inheritsPopupMenu = value;
1472:                firePropertyChange(INHERITS_POPUP_MENU_PROPERTY_NAME, oldValue,
1473:                        value);
1474:            }
1475:
1476:            public boolean getInheritsPopupMenu() {
1477:                return inheritsPopupMenu;
1478:            }
1479:
1480:            public void setComponentPopupMenu(JPopupMenu popup) {
1481:                JPopupMenu oldValue = componentPopupMenu;
1482:                componentPopupMenu = popup;
1483:                firePropertyChange(COMPONENT_POPUP_MENU_PROPERTY_NAME,
1484:                        oldValue, popup);
1485:            }
1486:
1487:            public JPopupMenu getComponentPopupMenu() {
1488:                JPopupMenu result = componentPopupMenu;
1489:                if (result == null && getInheritsPopupMenu()
1490:                        && (getParent() instanceof  JComponent)) {
1491:                    result = ((JComponent) getParent()).getComponentPopupMenu();
1492:                }
1493:                return result;
1494:            }
1495:
1496:            public Point getPopupLocation(MouseEvent event) {
1497:                return null;
1498:            }
1499:
1500:            <T extends EventListener> boolean hasListener(
1501:                    Class<T> listenerType, EventListener l) {
1502:                EventListener[] listeners = listenerList
1503:                        .getListeners(listenerType);
1504:                for (int i = 0; i < listeners.length; i++) {
1505:                    if (listeners[i] == l) {
1506:                        return true;
1507:                    }
1508:                }
1509:                return false;
1510:            }
1511:
1512:            void paintDoubleBuffered(Graphics g) {
1513:                Rectangle clipRect = g.getClipBounds();
1514:                if (clipRect == null) {
1515:                    clipRect = SwingUtilities.getLocalBounds(this );
1516:                }
1517:                Image image = RepaintManager.currentManager(this )
1518:                        .getVolatileOffscreenBuffer(this , clipRect.width + 1,
1519:                                clipRect.height + 1);
1520:                if (image == null) {
1521:                    return;
1522:                }
1523:                Graphics offscreenGraphics = image.getGraphics();
1524:                offscreenGraphics.translate(-clipRect.x, -clipRect.y);
1525:                offscreenGraphics.setClip(clipRect);
1526:                doubleBufferingRoot = true;
1527:                try {
1528:                    paint(getComponentGraphics(offscreenGraphics));
1529:                    g.drawImage(image, clipRect.x, clipRect.y, this );
1530:                } finally {
1531:                    doubleBufferingRoot = false;
1532:                    offscreenGraphics.dispose();
1533:                }
1534:            }
1535:
1536:            boolean insideDoubleBuffering() {
1537:                if (doubleBufferingRoot) {
1538:                    return true;
1539:                }
1540:                Component currentComponent = getParent();
1541:                while (currentComponent != null) {
1542:                    if (currentComponent instanceof  JComponent
1543:                            && ((JComponent) currentComponent).doubleBufferingRoot) {
1544:                        return true;
1545:                    }
1546:                    currentComponent = currentComponent.getParent();
1547:                }
1548:                return false;
1549:            }
1550:
1551:            private void addAncestorComponentNotifier() {
1552:                if (ancestorComponentNotifier != null) {
1553:                    return;
1554:                }
1555:                ancestorComponentNotifier = new AncestorComponentNotifier();
1556:                addHierarchyListener(ancestorComponentNotifier);
1557:                addHierarchyBoundsListener(ancestorComponentNotifier);
1558:                addComponentListener(ancestorComponentNotifier);
1559:            }
1560:
1561:            private void removeAncestorComponentNotifier() {
1562:                if (ancestorComponentNotifier == null
1563:                        || !Utilities.isEmptyArray(getAncestorListeners())) {
1564:                    return;
1565:                }
1566:                removeComponentListener(ancestorComponentNotifier);
1567:                removeHierarchyBoundsListener(ancestorComponentNotifier);
1568:                removeHierarchyListener(ancestorComponentNotifier);
1569:                ancestorComponentNotifier = null;
1570:            }
1571:
1572:            private Graphics getChildJComponentGraphics(Graphics g, Component c) {
1573:                Graphics result = g.create(c.getX(), c.getY(), c.getWidth(), c
1574:                        .getHeight());
1575:                return (c instanceof  JComponent) ? ((JComponent) c)
1576:                        .getComponentGraphics(result) : result;
1577:            }
1578:
1579:            private static boolean isDoubleBufferingEnabled(Component c) {
1580:                return c != null
1581:                        && (c.isDoubleBuffered() || isDoubleBufferingEnabled(c
1582:                                .getParent()));
1583:            }
1584:
1585:            /**
1586:             * @param rect is supposed to be initialized  with (0, 0, getWidth(), getHeight())
1587:             */
1588:            private static Rectangle getComponentVisibleRect(Component c,
1589:                    Rectangle rect) {
1590:                Rectangle result = rect;
1591:                auxRectangle.setBounds(0, 0, 0, 0);
1592:                Container ancestor = Utilities.getNotWindowParent(c);
1593:                while (ancestor != null && ancestor.isVisible()) {
1594:                    auxRectangle.setSize(ancestor.getSize());
1595:                    Rectangle translatedRect = SwingUtilities.convertRectangle(
1596:                            ancestor, auxRectangle, c);
1597:                    result = SwingUtilities.computeIntersection(result.x,
1598:                            result.y, result.width, result.height,
1599:                            translatedRect);
1600:                    ancestor = Utilities.getNotWindowParent(ancestor);
1601:                }
1602:                return result;
1603:            }
1604:            //    public void setFocusTraversalKeys(int id,
1605:            //            Set<T extends AWTKeyStroke> keystrokes) {
1606:            //
1607:            //    }
1608:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.