home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / 3rdParty / jbuilder / unsupported / JDK1.2beta3 / SOURCE / SRC.ZIP / java / awt / swing / JApplet.java < prev    next >
Encoding:
Java Source  |  1998-03-20  |  23.1 KB  |  763 lines

  1. /*
  2.  * @(#)JApplet.java    1.21 98/02/10
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package java.awt.swing;
  21.  
  22. import java.awt.*;
  23. import java.awt.event.*;
  24. import java.applet.Applet;
  25. import java.beans.PropertyChangeListener;
  26. import java.util.Locale;
  27. import java.util.Vector;
  28. import java.io.Serializable;
  29. import java.awt.accessibility.*;
  30.  
  31. /**
  32.  * An extended version of java.applet.Applet that adds support for 
  33.  * interposing input and painting behavior in front of the applets
  34.  * children (see glassPane), support for special children that 
  35.  * are managed by a LayeredPane (see rootPane) and for Swing MenuBars.
  36.  * <p>
  37.  * The JApplet class is slightly incompatible with java.applet.Applet.
  38.  * JApplet contains a JRootPane as it's only child.
  39.  * The <b>contentPane</b> should be the parent of any children of the JApplet.
  40.  * This is different than java.applet.Applet, e.g. to add a child to 
  41.  * an an java.applet.Applet you'd write:
  42.  * <pre>
  43.  *       applet.add(child);
  44.  * </pre>
  45.  * However using JApplet you need to add the child to the JApplet's contentPane
  46.  * instead:
  47.  * <pre>
  48.  *       applet.getContentPane().add(child);
  49.  * </pre>
  50.  * The same is true for setting LayoutManagers, removing components,
  51.  * listing children, etc. All these methods should normally be sent to
  52.  * the contentPane() instead of the JApplet itself. The contentPane() will
  53.  * always be non-null. Attempting to set it to null will cause the JApplet
  54.  * to throw an exception. The default contentPane() will have a BorderLayout
  55.  * manager set on it. 
  56.  * <p>
  57.  * Please see the JRootPane documentation for a complete description of
  58.  * the contentPane, glassPane, and layeredPane properties.
  59.  * <p>
  60.  * Warning: serialized objects of this class will not be compatible with
  61.  * future swing releases.  The current serialization support is appropriate 
  62.  * for short term storage or RMI between Swing1.0 applications.  It will
  63.  * not be possible to load serialized Swing1.0 objects with future releases
  64.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  65.  * baseline for the serialized form of Swing objects.
  66.  *
  67.  * @beaninfo
  68.  *      attribute: isContainer true
  69.  *      attribute: containerDelegate getContentPane
  70.  *    description: Swing's Applet subclass.
  71.  *
  72.  * @version 1.21 02/10/98
  73.  * @author Arnaud Weber
  74.  */
  75. public class JApplet extends Applet implements Accessible, RootPaneContainer 
  76. {
  77.     private static final BorderLayout sharedBorderLayout = new BorderLayout();
  78.  
  79.     /**
  80.      * @see #getRootPane
  81.      * @see #setRootPane
  82.      */
  83.     protected JRootPane rootPane;
  84.  
  85.     /**
  86.      * @see #isRootPaneCheckingEnabled
  87.      * @see #setRootPaneCheckingEnabled
  88.      */
  89.     protected boolean rootPaneCheckingEnabled = false;
  90.  
  91.     /**
  92.      * Creates a swing applet instance.
  93.      */
  94.     public JApplet() {
  95.         super();
  96.         setLayout(sharedBorderLayout);
  97.     setRootPane(createRootPane());
  98.     setRootPaneCheckingEnabled(true);
  99.     }
  100.  
  101.  
  102.     public void addNotify() {
  103.         super.addNotify();
  104.         enableEvents(AWTEvent.KEY_EVENT_MASK);
  105.     if (SwingUtilities.getAncestorOfClass(RootPaneContainer.class, this) == null) {
  106.             TimerQueue.initAppletTimer(this);
  107.         }
  108.         /** Here we need to call setVisible(true) now, otherwise it will be 
  109.          *  called later after calling init().
  110.          *  This may cause the timer panel to return false from isShowing(),
  111.          *  causing exception with the event queue 
  112.          */
  113.         setVisible(true);
  114.     }
  115.  
  116.     public void removeNotify() {
  117.         super.removeNotify();
  118.         TimerQueue.removeAppletTimer(this);
  119.     }
  120.  
  121.     /** Called by the constructor methods to create the default rootPane. */
  122.     protected JRootPane createRootPane() {
  123.     return new JRootPane();
  124.     }
  125.     
  126.     protected void processKeyEvent(KeyEvent e) {
  127.         super.processKeyEvent(e);
  128.         if(!e.isConsumed()) {
  129.             JComponent.processKeyBindingsForAllComponents(e,this,new Vector(),e.getID() == KeyEvent.KEY_PRESSED);
  130.         }
  131.     }
  132.  
  133.  
  134.     /** 
  135.      * Just calls <code>paint(g)</code>.  This method was overridden to 
  136.      * prevent an unneccessary call to clear the background.
  137.      */
  138.     public void update(Graphics g) {
  139.         paint(g);
  140.     }
  141.  
  142.    /**
  143.     * Sets the menubar for this applet.
  144.     * @param menubar the menubar being placed in the applet
  145.     *
  146.     * @see #getJMenuBar
  147.     *
  148.     * @beaninfo
  149.     *      hidden: true
  150.     * description: The menubar for accessing pulldown menus from this applet.
  151.     */
  152.     public void setJMenuBar(JMenuBar menuBar) {
  153.     getRootPane().setMenuBar(menuBar);
  154.     }
  155.  
  156.    /**
  157.     * Returns the menubar set on this applet.
  158.     *
  159.     * @see #setJMenuBar
  160.     */
  161.     public JMenuBar getJMenuBar() {
  162.         return getRootPane().getMenuBar();
  163.     }
  164.  
  165.  
  166.     /**
  167.      * @return true if add and setLayout should be checked
  168.      * @see #addImpl
  169.      * @see #setLayout
  170.      * @see #setRootPaneCheckingEnabled
  171.      */
  172.     protected boolean isRootPaneCheckingEnabled() {
  173.     return rootPaneCheckingEnabled;
  174.     }
  175.  
  176.  
  177.     /**
  178.      * If true then calls to add() and setLayout() will cause an exception
  179.      * to be thrown.  
  180.      *
  181.      * @see #addImpl
  182.      * @see #setLayout
  183.      * @see #isRootPaneCheckingEnabled
  184.      */
  185.     protected void setRootPaneCheckingEnabled(boolean enabled) {
  186.     rootPaneCheckingEnabled = enabled;
  187.     }
  188.  
  189.  
  190.     /**
  191.      * Create an runtime exception with a message like:
  192.      * <pre>
  193.      * "Do not use JApplet.add() use JApplet.getContentPane().add() instead"
  194.      * </pre>
  195.      */
  196.     private Error createRootPaneException(String op) {
  197.     String type = getClass().getName();
  198.     return new Error(
  199.             "Do not use " + type + "." + op + "() use " 
  200.                           + type + ".getContentPane()." + op + "() instead");
  201.     }
  202.  
  203.  
  204.     /**
  205.      * By default, children may not be added directly to a this component,
  206.      * they must be added to its contentPane instead.  For example:
  207.      * <pre>
  208.      * thiComponent.getContentPane().add(child)
  209.      * </pre>
  210.      * An attempt to add to directly to this component will cause an
  211.      * runtime exception to be thrown.  Subclasses can disable this
  212.      * behavior.
  213.      * 
  214.      * @see #setRootPaneCheckingEnabled
  215.      * @exception Error if called with rootPaneChecking true
  216.      */
  217.     protected void addImpl(Component comp, Object constraints, int index) 
  218.     {
  219.         if(isRootPaneCheckingEnabled()) {
  220.         throw createRootPaneException("add");
  221.     }
  222.     else {
  223.         super.addImpl(comp, constraints, index);
  224.     }
  225.     }
  226.  
  227.  
  228.     /**
  229.      * By default the layout of this component may not be set,
  230.      * the layout of its contentPane should be set instead.  
  231.      * For example:
  232.      * <pre>
  233.      * thiComponent.getContentPane().setLayout(new BorderLayout())
  234.      * </pre>
  235.      * An attempt to set the layout of this component will cause an
  236.      * runtime exception to be thrown.  Subclasses can disable this
  237.      * behavior.
  238.      * 
  239.      * @see #setRootPaneCheckingEnabled
  240.      * @exception Error if called with rootPaneChecking true
  241.      */
  242.     public void setLayout(LayoutManager manager) {
  243.         if(isRootPaneCheckingEnabled()) {
  244.         throw createRootPaneException("setLayout");
  245.     }
  246.     else {
  247.         super.setLayout(manager);
  248.     }
  249.     }
  250.  
  251.  
  252.     /**
  253.      * Returns the rootPane object for this applet.
  254.      *
  255.      * @see #setRootPane
  256.      * @see RootPaneContainer#getRootPane
  257.      */
  258.     public JRootPane getRootPane() { 
  259.     return rootPane; 
  260.     }
  261.  
  262.  
  263.     /**
  264.      * Sets the rootPane property.  This method is called by the constructor.
  265.      * @param root the rootPane object for this applet
  266.      *
  267.      * @see #getRootPane
  268.      * @see RootPaneContainer#setRootPane
  269.      *
  270.      * @beaninfo
  271.      *   hidden: true
  272.      * description: the RootPane object for this applet.
  273.      */
  274.     protected void setRootPane(JRootPane root) {
  275.     if(rootPane != null) {
  276.         remove(rootPane);
  277.     }
  278.     rootPane = root;
  279.     if(rootPane != null) {
  280.         boolean checkingEnabled = isRootPaneCheckingEnabled();
  281.         try {
  282.         setRootPaneCheckingEnabled(false);
  283.         add(rootPane, BorderLayout.CENTER);
  284.         }
  285.         finally {
  286.         setRootPaneCheckingEnabled(checkingEnabled);
  287.         }
  288.         }
  289.     }
  290.  
  291.  
  292.     /**
  293.      * Returns the contentPane object for this applet.
  294.      *
  295.      * @see #setContentPane
  296.      * @see RootPaneContainer#getContentPane
  297.      */
  298.     public Container getContentPane() { 
  299.     return getRootPane().getContentPane(); 
  300.     }
  301.  
  302.    /**
  303.      * Sets the contentPane property.  This method is called by the constructor.
  304.      * @param contentPane the contentPane object for this applet
  305.      *
  306.      * @see #getContentPane
  307.      * @see RootPaneContainer#setContentPane
  308.      *
  309.      * @beaninfo
  310.      *     hidden: true
  311.      *     description: The client area of the applet where child 
  312.      *                  components are normally inserted.
  313.      */
  314.     public void setContentPane(Container contentPane) {
  315.     getRootPane().setContentPane(contentPane);
  316.     }
  317.  
  318.     /**
  319.      * Returns the layeredPane object for this applet.
  320.      *
  321.      * @see #setLayeredPane
  322.      * @see RootPaneContainer#getLayeredPane
  323.      */
  324.     public JLayeredPane getLayeredPane() { 
  325.     return getRootPane().getLayeredPane(); 
  326.     }
  327.  
  328.     /**
  329.      * Sets the layeredPane property.  This method is called by the constructor.
  330.      * @param layeredPane the layeredPane object for this applet
  331.      *
  332.      * @see #getLayeredPane
  333.      * @see RootPaneContainer#setLayeredPane
  334.      *
  335.      * @beaninfo
  336.      *     hidden: true
  337.      *     description: The pane which holds the various applet layers.
  338.      */
  339.     public void setLayeredPane(JLayeredPane layeredPane) {
  340.     getRootPane().setLayeredPane(layeredPane);
  341.     }
  342.  
  343.     /**
  344.      * Returns the glassPane object for this applet.
  345.      *
  346.      * @see #setGlassPane
  347.      * @see RootPaneContainer#getGlassPane
  348.      */
  349.     public Component getGlassPane() { 
  350.     return getRootPane().getGlassPane(); 
  351.     }
  352.  
  353.     /**
  354.      * Sets the glassPane property. 
  355.      * This method is called by the constructor.
  356.      * @param glassPane the glassPane object for this applet
  357.      *
  358.      * @see #getGlassPane
  359.      * @see RootPaneContainer#setGlassPane
  360.      *
  361.      * @beaninfo
  362.      *     hidden: true
  363.      *     description: A transparent pane used for menu rendering.
  364.      */
  365.     public void setGlassPane(Component glassPane) {
  366.     getRootPane().setGlassPane(glassPane);
  367.     }
  368.  
  369.  
  370.  
  371. /////////////////
  372. // Accessibility support
  373. ////////////////
  374.  
  375.     protected AccessibleContext accessibleContext = null;
  376.  
  377.     /**
  378.      * Get the AccessibleContext associated with this JApplet
  379.      *
  380.      * @return the AccessibleContext of this JApplet
  381.      */
  382.     public AccessibleContext getAccessibleContext() {
  383.     if (accessibleContext == null) {
  384.         accessibleContext = new AccessibleJApplet();
  385.     }
  386.     return accessibleContext;
  387.     }
  388.  
  389.     protected class AccessibleJApplet extends AccessibleContext
  390.     implements Serializable, AccessibleComponent {
  391.  
  392.         // AccessibleContext methods
  393.         //
  394.         /**
  395.          * Get the role of this object.
  396.          *
  397.          * @return an instance of AccessibleRole describing the role of the 
  398.      * object
  399.          * @see AccessibleRole
  400.          */
  401.         public AccessibleRole getAccessibleRole() {
  402.         return AccessibleRole.FRAME;
  403.         }
  404.  
  405.         /**
  406.          * Get the state of this object.
  407.          *
  408.          * @return an instance of AccessibleStateSet containing the current 
  409.      * state set of the object
  410.          * @see AccessibleState
  411.          */
  412.         public AccessibleStateSet getAccessibleStateSet() {
  413.         AccessibleStateSet states = SwingUtilities.getAccessibleStateSet(JApplet.this);
  414.         states.add(AccessibleState.ACTIVE);
  415.         return states;
  416.         }
  417.  
  418.         /**
  419.          * Get the Accessible parent of this object.  If the parent of this
  420.          * object implements Accessible, this method should simply return
  421.          * getParent().
  422.          *
  423.          * @return the Accessible parent of this object -- can be null if this
  424.          * object does not have an Accessible parent
  425.          */
  426.         public Accessible getAccessibleParent() {
  427.             Container parent = getParent();
  428.             if (parent instanceof Accessible) {
  429.                 return (Accessible) parent;
  430.             } else {
  431.                 return null;
  432.             }
  433.         }
  434.  
  435.         /**
  436.          * Get the index of this object in its accessible parent. 
  437.          *
  438.          * @return the index of this object in its parent; -1 if this 
  439.          * object does not have an accessible parent.
  440.          * @see #getAccessibleParent
  441.          */
  442.         public int getAccessibleIndexInParent() {
  443.         return SwingUtilities.getAccessibleIndexInParent(JApplet.this);
  444.         }
  445.  
  446.         /**
  447.          * Returns the number of accessible children in the object.  If all
  448.          * of the children of this object implement Accessible, than this
  449.          * method should return the number of children of this object.
  450.          *
  451.          * @return the number of accessible children in the object.
  452.          */
  453.         public int getAccessibleChildrenCount() {
  454.         return SwingUtilities.getAccessibleChildrenCount(JApplet.this);
  455.         }
  456.  
  457.         /**
  458.          * Return the nth Accessible child of the object.  
  459.          *
  460.          * @param i zero-based index of child
  461.          * @return the nth Accessible child of the object
  462.          */
  463.         public Accessible getAccessibleChild(int i) {
  464.             return SwingUtilities.getAccessibleChild(JApplet.this,i);
  465.         }
  466.  
  467.         /**
  468.          * Return the locale of this object.
  469.      *
  470.          * @return the locale of this object
  471.          */
  472.         public Locale getLocale() {
  473.             return JApplet.this.getLocale();
  474.         }
  475.  
  476.         /**
  477.          * Get the AccessibleComponent associated with this object if one
  478.          * exists.  Otherwise return null.
  479.          */
  480.     public AccessibleComponent getAccessibleComponent() {
  481.         return this;
  482.     }
  483.  
  484.  
  485.         // AccessibleComponent methods
  486.         //
  487.         /**
  488.          * Get the background color of this object.
  489.          *
  490.          * @return the background color, if supported, of the object; 
  491.          * otherwise, null
  492.          */
  493.         public Color getBackground() {
  494.         return JApplet.this.getBackground();
  495.     }
  496.  
  497.         /**
  498.          * Set the background color of this object.
  499.          *
  500.          * @param c the new Color for the background
  501.          */
  502.         public void setBackground(Color c) {
  503.         JApplet.this.setBackground(c);
  504.     }
  505.  
  506.         /**
  507.          * Get the foreground color of this object.
  508.          *
  509.          * @return the foreground color, if supported, of the object; 
  510.          * otherwise, null
  511.          */
  512.         public Color getForeground() {
  513.         return JApplet.this.getForeground();
  514.     }
  515.  
  516.         /**
  517.          * Set the foreground color of this object.
  518.          *
  519.          * @param c the new Color for the foreground
  520.          */
  521.         public void setForeground(Color c) {
  522.         JApplet.this.setForeground(c);
  523.     }
  524.  
  525.         /**
  526.          * Get the Cursor of this object.
  527.          *
  528.          * @return the Cursor, if supported, of the object; otherwise, null
  529.          */
  530.         public Cursor getCursor() {
  531.         return JApplet.this.getCursor();
  532.     }
  533.  
  534.         /**
  535.          * Set the Cursor of this object.
  536.          *
  537.          * @param c the new Cursor for the object
  538.          */
  539.         public void setCursor(Cursor cursor) {
  540.         JApplet.this.setCursor(cursor);
  541.     }
  542.  
  543.         /**
  544.          * Get the Font of this object.
  545.          *
  546.          * @return the Font,if supported, for the object; otherwise, null
  547.          */
  548.         public Font getFont() {
  549.         return JApplet.this.getFont();
  550.     }
  551.  
  552.         /**
  553.          * Set the Font of this object.
  554.          *
  555.          * @param f the new Font for the object
  556.          */
  557.         public void setFont(Font f) {
  558.         JApplet.this.setFont(f);
  559.     }
  560.  
  561.         /**
  562.          * Get the FontMetrics of this object.
  563.          *
  564.          * @param f the Font
  565.          * @return the FontMetrics, if supported, the object; otherwise, null
  566.          * @see getFont
  567.          */
  568.         public FontMetrics getFontMetrics(Font f) {
  569.         return JApplet.this.getFontMetrics(f);
  570.     }
  571.  
  572.         /**
  573.          * Determine if the object is enabled.
  574.          *
  575.          * @return true if object is enabled; otherwise, false
  576.          */
  577.         public boolean isEnabled() {
  578.         return JApplet.this.isEnabled();
  579.     }
  580.  
  581.         /**
  582.          * Set the enabled state of the object.
  583.          *
  584.          * @param b if true, enables this object; otherwise, disables it 
  585.          */
  586.         public void setEnabled(boolean b) {
  587.         JApplet.this.setEnabled(b);
  588.     }
  589.     
  590.         /**
  591.          * Determine if the object is visible.  Note: this means that the
  592.          * object intends to be visible; however, it may not in fact be
  593.          * showing on the screen because one of the objects that this object
  594.          * is contained by is not visible.  To determine if an object is
  595.          * showing on the screen, use isShowing().
  596.          *
  597.          * @return true if object is visible; otherwise, false
  598.          */
  599.         public boolean isVisible() {
  600.         return JApplet.this.isVisible();
  601.     }
  602.  
  603.         /**
  604.          * Set the visible state of the object.
  605.          *
  606.          * @param b if true, shows this object; otherwise, hides it 
  607.          */
  608.         public void setVisible(boolean b) {
  609.         JApplet.this.setVisible(b);
  610.     }
  611.  
  612.         /**
  613.          * Determine if the object is showing.  This is determined by checking
  614.          * the visibility of the object and ancestors of the object.  Note: 
  615.      * this will return true even if the object is obscured by another 
  616.      * (for example, it happens to be underneath a menu that was pulled 
  617.      * down).
  618.          *
  619.          * @return true if object is showing; otherwise, false
  620.          */
  621.         public boolean isShowing() {
  622.         return JApplet.this.isShowing();
  623.     }
  624.  
  625.         /** 
  626.          * Checks whether the specified point is within this object's bounds,
  627.          * where the point's x and y coordinates are defined to be relative to 
  628.      * the coordinate system of the object. 
  629.          *
  630.          * @param p the Point relative to the coordinate system of the object
  631.          * @return true if object contains Point; otherwise false
  632.          */
  633.         public boolean contains(Point p) {
  634.         return JApplet.this.contains(p);
  635.     }
  636.     
  637.         /** 
  638.          * Returns the location of the object on the screen.
  639.          *
  640.          * @return location of object on screen -- can be null if this object
  641.          * is not on the screen
  642.          */
  643.         public Point getLocationOnScreen() {
  644.         return JApplet.this.getLocationOnScreen();
  645.     }
  646.  
  647.         /** 
  648.          * Gets the location of the object relative to the parent in the form 
  649.          * of a point specifying the object's top-left corner in the screen's 
  650.          * coordinate space.
  651.          *
  652.          * @return An instance of Point representing the top-left corner of 
  653.      * the objects's bounds in the coordinate space of the screen; null if
  654.          * this object or its parent are not on the screen
  655.          */
  656.     public Point getLocation() {
  657.         return JApplet.this.getLocation();
  658.     }
  659.  
  660.         /** 
  661.          * Sets the location of the object relative to the parent.
  662.          */
  663.         public void setLocation(Point p) {
  664.         JApplet.this.setLocation(p);
  665.     }
  666.  
  667.         /** 
  668.          * Gets the bounds of this object in the form of a Rectangle object. 
  669.          * The bounds specify this object's width, height, and location
  670.          * relative to its parent. 
  671.          *
  672.          * @return A rectangle indicating this component's bounds; null if 
  673.      * this object is not on the screen.
  674.          */
  675.         public Rectangle getBounds() {
  676.         return JApplet.this.getBounds();
  677.     }
  678.  
  679.         /** 
  680.          * Sets the bounds of this object in the form of a Rectangle object. 
  681.          * The bounds specify this object's width, height, and location
  682.          * relative to its parent.
  683.          *    
  684.          * @param A rectangle indicating this component's bounds
  685.          */
  686.         public void setBounds(Rectangle r) {
  687.         JApplet.this.setBounds(r);
  688.     }
  689.  
  690.         /** 
  691.          * Returns the size of this object in the form of a Dimension object. 
  692.          * The height field of the Dimension object contains this objects's
  693.          * height, and the width field of the Dimension object contains this 
  694.      * object's width. 
  695.          *
  696.          * @return A Dimension object that indicates the size of this 
  697.      * component; null if this object is not on the screen
  698.          */
  699.         public Dimension getSize() {
  700.         return JApplet.this.getSize();
  701.     }
  702.  
  703.         /** 
  704.          * Resizes this object so that it has width width and height. 
  705.          *    
  706.          * @param d - The dimension specifying the new size of the object. 
  707.          */
  708.         public void setSize(Dimension d) {
  709.         JApplet.this.setSize(d);
  710.     }
  711.  
  712.         /**
  713.          * Returns the Accessible child, if one exists, contained at the local
  714.      * coordinate Point.
  715.          *
  716.          * @param p The point defining the top-left corner of the Accessible, 
  717.      * given in the coordinate space of the object's parent. 
  718.          * @return the Accessible, if it exists, at the specified location; 
  719.      * else null
  720.          */
  721.         public Accessible getAccessibleAt(Point p) {
  722.         return SwingUtilities.getAccessibleAt(JApplet.this,p);
  723.     }
  724.  
  725.         /**
  726.          * Returns whether this object can accept focus or not.
  727.          *
  728.          * @return true if object can accept focus; otherwise false
  729.          */
  730.         public boolean isFocusTraversable() {
  731.         return JApplet.this.isFocusTraversable();
  732.     }
  733.  
  734.         /**
  735.          * Requests focus for this object.
  736.          */
  737.         public void requestFocus() {
  738.         JApplet.this.requestFocus();
  739.         }
  740.  
  741.         /**
  742.          * Adds the specified focus listener to receive focus events from this 
  743.          * component. 
  744.          *
  745.          * @param l the focus listener
  746.          */
  747.         public void addFocusListener(FocusListener l) {
  748.         JApplet.this.addFocusListener(l);
  749.     }
  750.  
  751.         /**
  752.          * Removes the specified focus listener so it no longer receives focus 
  753.          * events from this component.
  754.          *
  755.          * @param l the focus listener
  756.          */
  757.         public void removeFocusListener(FocusListener l) {
  758.         JApplet.this.removeFocusListener(l);
  759.     }
  760.     } // inner class AccessibleJApplet
  761. }
  762.  
  763.